/*获取订单号*/
var orderId = sessionStorage.getItem("supplementOrderid");
var memberIds = ""
var platforms = ""
var pushOrdererrorCode=1//下推订单状态
getOrderDetail();

/*通过订单号获取订单详情*/
function getOrderDetail() {


    $.ajax({
        type: "POST",
        /*root.orderInter.order_queryOrderDetails*/
        url: root.orderInter.order_queryOrderDetails,
        cache: false, //禁用缓存
        dataType: "json",
        data: {
            order_id: orderId, // 订单编号
        },
        success: function (result) {

            if (result.orderBase.change_price == 10) {
                $("#datatable").html("<thead>\n" +
                    "                    <tr >\n" +
                    "                        <th style=\"width: 300px;\">商品</th>\n" +
                    "                        <th>发货仓</th>\n" +
                    "                        <th>购买数量</th>\n" +
                    "                        <th>出库数量</th>\n" +
                    "                        <th>收货数量</th>\n" +
                    "                        <th>退货数量</th>\n" +
                    "                        <th>单价</th>\n" +
                    "                        <th>满减券分摊</th>\n" +
                    "                        <th>运费分摊</th>\n" +
                    "                        <th>促销分摊</th>\n" +
                    "                        <th>积分分摊</th>\n" +
                    "                        <th>小计</th>\n" +
                    "                    </tr>\n" +
                    "                    </thead>\n" +
                    "                    <tbody class=\"shun\">\n" +
                    "                    </tbody>");
            } else {
                $("#datatable").html("<thead>\n" +
                    "                    <tr >\n" +
                    "                        <th style=\"width: 300px;\">商品</th>\n" +
                    "                        <th>发货仓</th>\n" +
                    "                        <th>购买数量</th>\n" +
                    "                        <th>出库数量</th>\n" +
                    "                        <th>收货数量</th>\n" +
                    "                        <th>退货数量</th>\n" +
                    "                        <th>单价</th>\n" +
                    "                        <th>新单价</th>\n" +
                    "                        <th>满减券分摊</th>\n" +
                    "                        <th>运费分摊</th>\n" +
                    "                        <th>促销分摊</th>\n" +
                    "                        <th>积分分摊</th>\n" +
                    "                        <th>小计</th>\n" +
                    "                        <th>新小计</th>\n" +
                    "                    </tr>\n" +
                    "                    </thead>\n" +
                    "                    <tbody class=\"shun\">\n" +
                    "                    </tbody>");
            }


            if (result.orderBase != null) {
                memberIds = result.orderBase.member_id
            }
            if (result.orderExt != null) {
                platforms = result.orderExt.platform
            }


            if (result.listOrderAttachment != "" && result.listOrderAttachment != null) {
                $("#enclosure").css({
                    display: "block"
                });
            }


            sessionStorage.removeItem("Identification");
            if (result.listOrderRefund != null && result.listOrderRefund != '') {
                $("#returnInfoBox").css({
                    display: "block"
                });
            } else {
                $("#returnInfoBox").css({
                    display: "none"
                });
            }

            //询价单号展示
            if (result.inquiry_num != '' && result.orderExt.order_type == 20) {
                $("#inquiry").css({
                    display: "inline"
                });
            }
            //优惠劵，运费卷展示
            if (result.orderCoupon != "" && result.orderCoupon != null) {
                if (result.orderCoupon.coupon_type == 10) {
                    $("#couponInfo11").css({
                        display: "inline"
                    });
                } else {
                    $("#couponInfsfo11").css({
                        display: "inline"
                    });
                }
            }
            //查看取货信息按钮展示
            if(result.orderBase.order_status!=9&&result.orderBase.order_status!=10){
                if(result.orderExt.sent_type==50 && result.initPayWay=="在线支付"){
                    $("#seeInformation").css({
                        display: "inline"
                    });
                }else {
                    $("#seeInformation").css({
                        display: "none"
                    });
                }
            }

            //上门自提
            if (result.orderExt.sent_type == 50) {
                $("#selftakein").css({
                    display: "block"
                });
                $("#selftakeshop").css({
                    display: "block"
                });
                $("#receiverdetailaddress").css({
                    display: "block"
                });
                $("#selftakephone").css({
                    display: "block"
                });
                $("#wanna_edin").css({
                    display: "none"
                });
                $("#predixttime").css({
                    display: "none"
                });
            } else {
                $("#selftakein").css({
                    display: "none"
                });
                $("#selftakeshop").css({
                    display: "none"
                });
                $("#receiverdetailaddress").css({
                    display: "none"
                });
                $("#selftakephone").css({
                    display: "none"
                });
                $("#wanna_edin").css({
                    display: "block"
                });
                $("#predixttime").css({
                    display: "block"
                });
            }
            if (result.orderWarning != null && result.orderWarning.warning_status == 20) {
                $("#relieverole").css({
                    display: "block"
                });
                $("#operatedat").css({
                    display: "block"
                });
            }

            //发票类型展示
            if (result.orderInvoice != null) {
                if (result.orderInvoice.invoice_type == 20 && result.orderInvoice.invoice_title == '个人') {

                    $("#invoice-type1").show();
                    $("#invoice_t").css({
                        display: "none"
                    });
                    $("#taxpayer_identify_num1").css({
                        display: "none"
                    });
                    $("#register_address1").hide()
                    $("#register_phone1").hide()
                    $("#open_bank1").hide()
                    $("#bank_account1").hide()

                } else {
                    $("#invoice-type1").show()
                    $("#invoice_t").css({
                        display: "inline"
                    });
                    $("#taxpayer_identify_num1").css({
                        display: "inline"
                    });
                    $("#register_address1").hide()
                    $("#register_phone1").hide()
                    $("#open_bank1").hide()
                    $("#bank_account1").hide()

                }

                if (result.orderInvoice.invoice_type == 10) {
                    $("#invoice-type1").show()
                    $("#invoice_t").css({
                        display: "inline"
                    });
                    $("#taxpayer_identify_num1").css({
                        display: "inline"
                    });
                    $("#register_address1").show()
                    $("#register_phone1").show()
                    $("#open_bank1").show()
                    $("#bank_account1").show()
                }
            } else {
                $("#invoice-type1").show()
                $("#invoice_t").css({
                    display: "none"
                });
                $("#taxpayer_identify_num1").css({
                    display: "none"
                });
                $("#register_address1").hide()
                $("#register_phone1").hide()
                $("#open_bank1").hide()
                $("#bank_account1").hide()
            }

            //客户客服显示
            /* for(var i = 0; i < result.listOrderVerifyRecord.length; i++) {

                if(result.listOrderVerifyRecord[i].account_type == 10 && result.listOrderVerifyRecord[i].verify_status == 0) {
                    console.log('客户');
                   /!* $("#customerCheckdsgs").show()
                    $("#customerServiceCheckdfh").hide()*!/
                    $("#customerCheckdsgs").css({
                        display: "inline"
                    });
                    $("#customerServiceCheckdfh").css({
                        display: "none"
                    });
                }
            }
            if(result.orderBase.anomal_check == 10 && result.orderBase.order_status == 20) {
                console.log('客服');
                /!*$("#customerServiceCheckdfh").show()
                $("#customerCheckdsgs").hide()*!/
                $("#customerServiceCheckdfh").css({
                    display: "inline"
                });
                $("#customerCheckdsgs").css({
                    display: "none"
                });
            }*/
            /* for(var i = 0; i < result.listOrderVerifyRecord.length; i++) {

                if(result.listOrderVerifyRecord[i].account_type == 10 && result.listOrderVerifyRecord[i].verify_status == 0) {
                    console.log('客户111');
                    $('#customerCheckdsgs').removeAttr('style');
                    $('#customerServiceCheckdfh').removeAttr('style');
                    $("#customerCheckdsgs").show()
                    $("#customerServiceCheckdfh").hide()

                }else {
                    $("#customerCheckdsgs").hide()
                }
            }
            if(result.orderBase.anomal_check == 10 && result.orderBase.order_status == 20) {
                console.log('客服111');
                $('#customerCheckdsgs').removeAttr('style');
                $('#customerServiceCheckdfh').removeAttr('style');
                $("#customerServiceCheckdfh").show()
                $("#customerCheckdsgs").hide()

            }*/
            if (result.orderExt != null && result.orderExt.platform == 10) {
                $("#alsi").hide();
                $("#alisaAddress").hide();
            } else {
                $("#alsi").show();
                $("#alisaAddress").show();

            }
            if (result.orderExt != null && result.orderExt.platform == 10 || result.orderBase.order_status == 10 || result.orderBase.order_status == 20 || result.orderBase.order_status == 40 || result.orderBase.order_status == 50 || result.orderBase.order_status == 60 || result.orderBase.order_status == 70 || result.orderBase.order_status == 80 || result.orderBase.order_status == 90 || result.orderBase.order_status == 100 || result.orderBase.order_status == 110 || result.orderBase.order_status == 9) {
                $("#assassin").hide();
            } else {
                $("#assassin").show();
            }


            if (result.orderExt != null && result.orderExt.final_sent_type == 10) {

                $("#dexpress_company2").show();
                $("#eexpress_num").show();
                $("#cexpress_company").hide();
                $("#bdistributor-phone").hide();
                $("#adriver-phone").hide();
                $("#dexpress_company3").hide();
                $("#eexpress_num3").hide();


            } else if (result.orderExt != null && result.orderExt.final_sent_type == 20) {

                $("#dexpress_company3").show();
                $("#eexpress_num3").show();
                $("#cexpress_company").hide();
                $("#bdistributor-phone").hide();
                $("#adriver-phone").hide();
                $("#dexpress_company2").hide();
                $("#eexpress_num").hide();

            } else if (result.orderExt != null && result.orderExt.final_sent_type == 21) {

                $("#dexpress_company3").show();
                $("#eexpress_num3").show();
                $("#cexpress_company").hide();
                $("#bdistributor-phone").hide();
                $("#adriver-phone").hide();
                $("#dexpress_company2").hide();
                $("#eexpress_num").hide();

            } else if (result.orderExt != null && result.orderExt.final_sent_type == 30) {
                $("#cexpress_company").show();
                $("#adriver-phone").show();
                $("#bdistributor-phone").hide();
                $("#dexpress_company2").hide();
                $("#eexpress_num").hide();
                $("#dexpress_company3").hide();
                $("#eexpress_num3").hide();
            } else if (result.orderExt != null && result.orderExt.final_sent_type == 40) {
                $("#adriver-phone").show();
                $("#bdistributor-phone").show();
                $("#isSasssas").hide();
                $("#issdvssas").hide();
                $("#jshfjshd").show();
                $("#cexpress_company").hide();
                $("#dexpress_company2").hide();
                $("#eexpress_num").hide();
                $("#dexpress_company3").hide();
                $("#eexpress_num3").hide();
            } else if (result.orderExt != null && result.orderExt.final_sent_type == 50) {
                $("#adriver-phone").hide();
                $("#bdistributor-phone").hide();
                $("#cexpress_company").hide();
                $("#dexpress_company2").hide();
                $("#eexpress_num").hide();
                $("#dexpress_company3").hide();
                $("#eexpress_num3").hide();
            } else if (result.orderExt != null && result.orderExt.final_sent_type == 0) {
                $("#adriver-phone").hide();
                $("#bdistributor-phone").hide();
                $("#cexpress_company").hide();
                $("#dexpress_company2").hide();
                $("#eexpress_num").hide();
                $("#dexpress_company3").hide();
                $("#eexpress_num3").hide();
            }


            if (result.is_rejected != null && result.is_rejected == 1 && result.orderRefund.refund_status == 30) {
                $("#order_statue1").show();
                $("#order_statue2").hide();
                $("#returnGoods1").hide();
            } else {
                $("#order_statue1").hide();
                $("#order_statue2").hide();
                $("#returnGoods1").hide();
            }
            if (result.is_rejected != null && result.is_rejected == 0) {
                if (result.orderCancleApply != null && result.orderCancleApply.deal_status == 10) {

                    $("#order_statue1").show();
                    $("#order_statue2").show();
                    $("#returnGoods1").hide();

                } else if (result.orderCancleApply != null && result.orderCancleApply.deal_status == 20) {

                    $("#order_statue1").show();
                    $("#order_statue2").hide();
                    $("#returnGoods1").show();

                } else if (result.orderCancleApply != null && result.orderCancleApply.deal_status == 30) {
                    $("#order_statue1").hide();
                    $("#order_statue2").hide();
                    $("#returnGoods1").hide();
                }
            }


            console.log(result)
            sessionStorage.setItem("orderDetail", JSON.stringify(result));
            renderOrderPage(result);

            /* for (var i=0;i<result.listOrderRefund.length;i++) {
                $("#returnTable").append('<tr><td class="col-2-1">退货单号：<span id="returnId"></span><a onclick="returnOrderInfo(\'退货单详情\',\'../afterSale/afterSaleService-returns.html\',\''+result.listOrderRefund[i].refund_id+'\',\''+result.listOrderRefund[i].order_id+'\')">'+result.listOrderRefund[i].refund_id+'</a></td><td class="col-2-1">申请时间：<span id="applytime"></span><span>'+result.listOrderRefund[i].created_at+'</span></td></tr>')
            }*/
            if (result.listOrderRefund != null) {
                var listOrderRefunds = ""
                $.each(result.listOrderRefund, function (k, v) {

                    listOrderRefunds += '<tr><td class="col-2-1">退货单号：<span id="returnId"></span><a onclick="returnOrderInfo(\'退货单详情\',\'../afterSale/afterSaleService-returns.html\',\'' + v.refund_id + '\',\'' + v.order_id + '\')">' + v.refund_id + '</a></td><td class="col-2-1">申请时间：<span id="applytime"></span><span>' + v.created_at + '</span></td></tr>';
                })
                $("#returnTable").empty().append($(listOrderRefunds))

            }

            //将所有按钮隐藏
            $("#affirmMoney").siblings().css({
                display: "none"
            });
            /*确认认款按钮判断*/
            if ((result.orderBase.paid_type == 1301 || result.orderBase.paid_type == 1401)
                && (result.orderBase.order_status == 9 || result.orderBase.order_status == 10)) {

                if (result.orderBase.customer_verify_status == 0) {
                    /*$("#orderCheckStatus").css({
                        display: "inline"
                    });*/
                    $("#affirmMoney").css({
                        display: "none"
                    });
                }
                // if(result.orderBase.customer_verify_status == 10 && result.orderBase.anomal_check == 10){
                //     $("#orderAnomalCheckStatus").css({
                //         display: "inline"
                //     });
                //     $("#affirmMoney").css({
                //         display: "none"
                //     });
                // }
                if (result.orderBase.customer_verify_status == 10) {
                    $("#orderAnomalCheckStatus").css({
                        display: "none"
                    });
                    $("#affirmMoney").css({
                        display: "inline"
                    });
                }
                /*  for(var i = 0; i < result.listOrderVerifyRecord.length; i++) {
                    if(result.listOrderVerifyRecord[i].account_type == 10) {
                        if(result.listOrderVerifyRecord[i].verify_status == 0) {
                            $("#orderCheckStatus").css({
                                display: "inline"
                            });
                            $("#affirmMoney").css({
                                display: "none"
                            });
                        } else {
                            $("#orderCheckStatus").css({
                                display: "none"
                            });
                            $("#affirmMoney").css({
                                display: "inline"
                            });
                        }
                    }
                }*/
            } else if (result.orderBase.paid_type == 1101 && result.orderBase.order_status == 70) {
                if (result.listOrderRemark.length == 0) {
                    $("#comfirmMoneyRemark").val("");
                    $("#affirmMoney").css({
                        display: "inline"
                    })
                } else {
                    for (var i = 0; i < result.listOrderRemark.length; i++) {
                        if (result.listOrderRemark[i].operate_type == 10) {
                            $("#affirmMoney").css({
                                display: "inline"
                            })
                            $("#comfirmMoneyRemark").html(result.listOrderRemark[i].remark);//确认认款备注
                        } else {
                            $("#comfirmMoneyRemark").val("");
                            $("#affirmMoney").css({
                                display: "inline"
                            });
                        }
                    }
                }
            }
            switch (result.orderBase.order_status) {
                case 9:
                    /*待审核*/
                    for (var i = 0; i < result.listOrderVerifyRecord.length; i++) {

                        if (result.listOrderVerifyRecord[i].account_type == 10 && result.listOrderVerifyRecord[i].verify_status == 0) {
                            console.log('客户');

                            $("#customerCheckdsgs").css({
                                display: "inline"
                            });
                            $("#customerServiceCheckdfh").css({
                                display: "none"
                            });
                        }
                    }
                    if (result.orderBase.anomal_check == 10 && result.orderBase.order_status == 20) {
                        console.log('客服');

                        $("#customerServiceCheckdfh").css({
                            display: "inline"
                        });
                        $("#customerCheckdsgs").css({
                            display: "none"
                        });
                    }
                    //拆单按钮展示
                    if(result.order_class==10){
                        //主订单
                        if(result.orderBase.order_split_status==0){
                            //未拆单可操作按钮展示
                            $("#detailCancel").css({
                                display: "inline"
                            });

                            $("#isSaveFalse").css({
                                display: "block"
                            });
                        }else {
                            //拆单中或者已拆单可操作按钮隐藏
                            $("#detailCancel").css({
                                display: "none"
                            });

                            $("#isSaveFalse").css({
                                display: "none"
                            });

                        }

                    }else {
                        $("#detailCancel").css({
                            display: "inline"
                        });

                        $("#isSaveFalse").css({
                            display: "block"
                        });
                    }


                    break;
                case 10:
                    /*待付款*/
                    for (var i = 0; i < result.listOrderVerifyRecord.length; i++) {

                        if (result.listOrderVerifyRecord[i].account_type == 10 && result.listOrderVerifyRecord[i].verify_status == 0) {
                            console.log('客户');

                            $("#customerCheckdsgs").css({
                                display: "inline"
                            });
                            $("#customerServiceCheckdfh").css({
                                display: "none"
                            });
                        }
                    }
                    if (result.orderBase.anomal_check == 10) {
                        console.log('客服');

                        $("#customerServiceCheckdfh").css({
                            display: "none"
                        });
                        $("#customerCheckdsgs").css({
                            display: "none"
                        });
                    }
                    $("#detailCancel").css({
                        display: "inline"
                    });

                    break;
                /*订单状态*/
                case 20:
                    /*待审核*/
                    //拆单按钮展示
                    if(result.order_class==10){
                        //主订单
                        if(result.orderBase.order_split_status==0){
                            //未拆单可操作按钮展示
                            $("#detailCancel").css({
                                display: "inline"
                            });

                            $("#isSaveFalse").css({
                                display: "block"
                            });
                        }else {
                            //拆单中或者已拆单可操作按钮隐藏
                            $("#detailCancel").css({
                                display: "none"
                            });

                            $("#isSaveFalse").css({
                                display: "none"
                            });

                        }

                    }else {
                        $("#detailCancel").css({
                            display: "inline"
                        });

                        $("#isSaveFalse").css({
                            display: "block"
                        });
                    }
                    for (var i = 0; i < result.listOrderVerifyRecord.length; i++) {

                        if (result.listOrderVerifyRecord[i].account_type == 10 && result.listOrderVerifyRecord[i].verify_status == 0) {
                            console.log('客户');
                            $("#customerCheckdsgs").css({
                                display: "inline"
                            });
                            $("#customerServiceCheckdfh").css({
                                display: "none"
                            });
                        }
                    }
                    if (result.orderBase.anomal_check == 10) {
                        console.log('客服');
                        $("#customerServiceCheckdfh").css({
                            display: "inline"
                        });
                        $("#customerCheckdsgs").css({
                            display: "none"
                        });
                    }
                    /* if(result.orderBase.paid_type == 1101 && result.orderBase.customer_verify_status == 0){
                        $("#orderCheckStatus").css({
                            display: "inline"
                        });
                        $("#detailCancel").css({
                            display: "inline"
                        });
                    }*/

                    $("#affirmMoney").css({
                        display: "none"
                    });
                    $("#orderSureStatus").css({
                        display: "none"
                    });
                    break;


                case 30:
                    /*待配货*/
                    $("#affirmMoney").css({
                        display: "none"
                    });
                    $(".updataBtn").css({
                        display: "inline"
                    });
                    $("#detailCancel").css({
                        display: "none"
                    });
                    //订单下推
                    if (result.push_button_show == true){
                        $("#pushOrder").css({
                            display: "inline"
                        });
                        $("#pushOrder2").css({
                            display: "inline"
                        });
                    }else {
                        $("#pushOrder").css({
                            display: "none"
                        });
                        $("#pushOrder2").css({
                            display: "none"
                        });
                    }

                    /*$("#clientRejection").css({
                        display: "inline"
                    });*/
                    break;
                case 40:
                    /*待出库*/
                    $("#pushOrder").css({
                        display: "none"
                    });
                    $("#pushOrder2").css({
                        display: "none"
                    });
                    $("#affirmMoney").css({
                        display: "none"
                    });

                    $("#jshfjshd").css({
                        display: "none"
                    });
                    if (result.cancle_apply_show == false) {
                        $("#quxiao").css({
                            display: "inline"
                        });
                        $("#detailCancel").css({
                            display: "none"
                        });
                    } else {
                        $("#quxiao").css({
                            display: "none"
                        });
                        $("#detailCancel").css({
                            display: "inline"
                        });

                    }
                    if (result.orderExt.common_order_type == 19653) {
                        $("#frglivergoods").css({
                            display: "inline"
                        });
                    }
                    if (result.orderExt.common_order_type == 19653) {

                        $("#delivery-method").html("厂家直发");
                    } else {

                        $("#delivery-method").html(changeDeliverthodType(result.orderExt.sent_type));

                    }

                function changeDeliverthodType(DeliveryMethodType) {
                    switch (DeliveryMethodType) {
                        /*配送方式*/
                        case 10:
                            return "快递";
                            break;
                        case 20:
                            return "快运-送货上门";
                            break;
                        case 30:
                            return "快运-站点自提";
                            break;
                        case 40:
                            return "鑫方盛物流";
                            break;
                        case 50:
                            return "上门自提";
                            break;
                        case 52:
                            return "配送客户自提";
                            break;

                    }
                }

                    break;
                case 50:
                    /*待发货*/
                    $("#pushOrder").css({
                        display: "none"
                    });
                    $("#pushOrder2").css({
                        display: "none"
                    });
                    $("#affirmMoney").css({
                        display: "none"
                    });
                    if (result.cancle_apply_show == false) {
                        $("#quxiao").css({
                            display: "inline"
                        });

                    } else {
                        $("#detailCancel").css({
                            display: "inline"
                        });

                    }


                    break;
                case 60:
                    /*待收货*/
                    $("#pushOrder").css({
                        display: "none"
                    });
                    $("#pushOrder2").css({
                        display: "none"
                    });
                    if (result.orderExt.final_sent_type == 40) {
                        $("#issdvssas").css({
                            display: "none"
                        });
                        $("#isSasssas").css({
                            display: "none"
                        });
                    } else {
                        $("#issdvssas").css({
                            display: "inline"
                        });
                        $("#isSasssas").css({
                            display: "inline"
                        });
                    }


                    $("#affirmMoney").css({
                        display: "none"
                    });


                    $("#isSvssas").css({
                        display: "inline"
                    });
                    $("#isSasdvssas").css({
                        display: "inline"
                    });
                    $("#isSasdseFalse").css({
                        display: "inline"
                    });
                    $("#isSasdeFalse").css({
                        display: "inline"
                    });
                    $("#ieFalse").css({
                        display: "inline"
                    });
                    $("#ieFlse").css({
                        display: "inline"
                    });

                    if (result.is_rejected != 1) {
                        $("#clientRejection").css({
                            display: "inline"
                        });
                    }

                    break;
                case 70:
                    /*已收货，待结算*/
                    $("#pushOrder").css({
                        display: "none"
                    });
                    $("#pushOrder2").css({
                        display: "none"
                    });
                    if (result.is_show == true) {
                        $("#maintain").css({
                            display: "inline"
                        });
                        $("#returnGoods").css({
                            display: "inline"
                        });
                    }
                    /* $("#returnInfoBox").css({
                        display: "block"
                    });*/
                    break;
                case 80:
                    /*订单成功*/
                    $("#pushOrder").css({
                        display: "none"
                    });
                    $("#pushOrder2").css({
                        display: "none"
                    });
                    $("#affirmMoney").css({
                        display: "none"
                    });


                    if (result.is_show == true) {
                        $("#maintain").css({
                            display: "inline"
                        });
                        $("#returnGoods").css({
                            display: "inline"
                        });
                    }
                    /* $("#returnInfoBox").css({
                        display: "block"
                    });*/
                    break;
                case 90:
                    /*交易完成*/
                    $("#pushOrder").css({
                        display: "none"
                    });
                    $("#pushOrder2").css({
                        display: "none"
                    });
                    $("#affirmMoney").css({
                        display: "none"
                    });
                    if (result.is_show == true) {
                        $("#maintain").css({
                            display: "inline"
                        });
                        $("#returnGoods").css({
                            display: "inline"
                        })
                    }
                    /* $("#returnInfoBox").css({
                        display: "block"
                    });*/
                    break;
                case 100:
                    /*已取消*/
                    $("#pushOrder").css({
                        display: "none"
                    });
                    $("#pushOrder2").css({
                        display: "none"
                    });
                    $("#affirmMoney").css({
                        display: "none"
                    });
                    $("#orderSureStatus").css({
                        display: "none"
                    });
                    $("#customerCheck").hide();
                    $("#customerServiceCheck").hide();
                    if (result.buy_again_button == true) {
                        $("#buyAgain").css({
                            display: "inline"
                        });
                    } else {
                        $("#buyAgain").css({
                            display: "none"
                        });
                    }

                    $("#cancleReason").css({
                        display: "inline"
                    });
                    if (result.orderCancle != null) {
                        if (result.orderCancle.cancel_role == 10) {
                            $("#cancleReason").html("客户主动取消");
                        } else if (result.orderCancle.cancel_role == 20) {
                            $("#cancleReason").html("客服取消");
                        } else if (result.orderCancle.cancel_role == 30) {
                            $("#cancleReason").html("超时未支付取消");
                        }
                    }

                    $(".cancleBox").css({
                        display: "inline"
                    });
                    /*$("#returnInfoBox").css({
                        display: "block"
                    });*/
                    break;
                case 110:
                    /*交易关闭*/
                    $("#pushOrder").css({
                        display: "none"
                    });
                    $("#pushOrder2").css({
                        display: "none"
                    });
                    $("#returnReason").css({
                        display: "inline"
                    });
                    $("#affirmMoney").css({
                        display: "none"
                    });
                    /* $("#returnInfoBox").css({
                        display: "block"
                    });*/
                    $(".closeBox").css({
                        display: "block"
                    });
                    break;
            }


            var handStr = '';
            var hdStr = '';
            var hdStrdf = ""
            var hdStrdfuu = ""
            var hdSdfuu = ""
            var warehouses = JSON.parse(sessionStorage.getItem("warehouses"))
            //满减金额商品
            if (result.fullAmountReduceOrderItemsMap != "" && result.fullAmountReduceOrderItemsMap != null) {
                var arr = result.fullAmountReduceOrderItemsMap
                $.each(arr, function (index, i) {
                    //算出该活动的所有商品小计和优惠值
                    let countMoney = 0;
                    let promotionMoney = 0;
                    $.each(arr[index], function (k, v) {
                        promotionMoney = Number(promotionMoney) + Number(v.promotion_value);
                        countMoney = Number(countMoney) + Number((v.sale_price * v.buyyer_count).toFixed(2));
                    })

                    let ruleStr = '<tr><td colspan="11"><div>' +
                        '<span style="float: left;">' + arr[index][0].activity_rule + '</span>' +
                        '<div style="float: right"><span style="float: left;">￥' + (countMoney).toFixed(2) + '</span><br>' +
                        '<span style="float: left;">减：' + (promotionMoney).toFixed(2) + '</span></div>' +
                        '</div></td></tr>';
                    handStr += ruleStr;

                    $.each(arr[index], function (k, v) {
                            var ss = ""
                            $.each(warehouses.data, function (k, s) {
                                if (result.orderBase.parent_warehouse_id == s.warehouseCode) {
                                    ss = s.warehouseName
                                }
                            })

                            //单价
                            var price = v.init_sale_price
                            var specialPrice = ""
                            if (v.activity_type == 10) {
                                specialPrice = v.promotion_value / v.buyyer_count
                            }
                            price = (price - specialPrice).toFixed(2)
                            //新单价
                            var newprice = v.sale_price
                            var newspecialPrice = ""
                            if (v.activity_type == 10) {
                                newspecialPrice = v.promotion_value / v.buyyer_count
                            }
                            newprice = (newprice - newspecialPrice).toFixed(2)
                            //运费分摊
                            var fares = ""
                            if (result.orderBase.separate_shipping_fee == 10) {
                                fares = "0"
                            } else {
                                fares = v.fare

                            }
                            //满减券分摊
                            var couponvalues = ""
                            if (result.orderCoupon != "" && result.orderCoupon != null) {

                                if (result.orderCoupon.coupon_type == 10) {
                                    couponvalues = v.coupon_value
                                } else {
                                    couponvalues = "0"
                                }
                            }
                            //小计
                            var substotle = (price * v.buyyer_count).toFixed(2);
                            //新小计
                            var newsubstotle = (newprice * v.buyyer_count).toFixed(2);

                            if (result.orderBase.change_price == 10) {
                                //未改价过的订单
                                if (v.spu_id == 0) {
                                    handStr += '<tr class="biaoge1">' +
                                        '<td class="biaoge1-1"><div style="cursor:pointer;"><img title="" style="float: left;width: 100px;height: 100px;" name="" src="' + v.product_pic + '" alt=""><div style="float: left;width:180px;padding-top: 20px;margin-left: 10px;"><div>' + v.sku_code + '</div><div>' + v.product_name + '</div><div>' + v.color + '</div><div>' + v.sku_info + '</div></div></div></td>' +
                                        '<td class="biaoge1-1"><span id="handle_man">' + ss + '</span></td>' +
                                        '<td class="biaoge1-2"><span id="handle_results">' + v.buyyer_count + '' + v.unit_name + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + v.delivery_count + '' + v.unit_name + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + v.receive_count + '' + v.unit_name + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + v.have_returned_count + '' + v.unit_name + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + price + '元/' + v.unit_name + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + couponvalues + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + fares + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + v.promotion_value + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + v.used_points + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + substotle + '元' + '</span></td>' +
                                        '</tr>';
                                } else {
                                    handStr += '<tr class="biaoge1">' +
                                        '<td class="biaoge1-1"><div style="cursor:pointer;"><img title="点击跳转sku列表" onclick="goToGoodsDetail(' + v.spu_id + ')"  style="float: left;width: 100px;height: 100px;" name="" src="' + v.product_pic + '" alt=""><div style="float: left;width:180px;padding-top: 20px;margin-left: 10px;"><div>' + v.sku_code + '</div><div>' + v.product_name + '</div><div>' + v.color + '</div><div>' + v.sku_info + '</div></div></div></td>' +
                                        '<td class="biaoge1-1"><span id="handle_man">' + ss + '</span></td>' +
                                        '<td class="biaoge1-2"><span id="handle_results">' + v.buyyer_count + '' + v.unit_name + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + v.delivery_count + '' + v.unit_name + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + v.receive_count + '' + v.unit_name + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + v.have_returned_count + '' + v.unit_name + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + price + '元/' + v.unit_name + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + couponvalues + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + fares + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + v.promotion_value + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + v.used_points + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + substotle + '元' + '</span></td>' +
                                        '</tr>';
                                }
                            } else {
                                //改过价格的订单
                                if (v.spu_id == 0) {
                                    handStr += '<tr class="biaoge1">' +
                                        '<td class="biaoge1-1"><div style="cursor:pointer;"><img title="" style="float: left;width: 100px;height: 100px;" name="" src="' + v.product_pic + '" alt=""><div style="float: left;width:180px;padding-top: 20px;margin-left: 10px;"><div>' + v.sku_code + '</div><div>' + v.product_name + '</div><div>' + v.color + '</div><div>' + v.sku_info + '</div></div></div></td>' +
                                        '<td class="biaoge1-1"><span id="handle_man">' + ss + '</span></td>' +
                                        '<td class="biaoge1-2"><span id="handle_results">' + v.buyyer_count + '' + v.unit_name + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + v.delivery_count + '' + v.unit_name + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + v.receive_count + '' + v.unit_name + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + v.have_returned_count + '' + v.unit_name + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + price + '元/' + v.unit_name + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + newprice + '元/' + v.unit_name + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + couponvalues + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + fares + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + v.promotion_value + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + v.used_points + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + substotle + '元' + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + newsubstotle + '元' + '</span></td>' +
                                        '</tr>';
                                } else {
                                    handStr += '<tr class="biaoge1">' +
                                        '<td class="biaoge1-1"><div style="cursor:pointer;"><img title="点击跳转sku列表" onclick="goToGoodsDetail(' + v.spu_id + ')"  style="float: left;width: 100px;height: 100px;" name="" src="' + v.product_pic + '" alt=""><div style="float: left;width:180px;padding-top: 20px;margin-left: 10px;"><div>' + v.sku_code + '</div><div>' + v.product_name + '</div><div>' + v.color + '</div><div>' + v.sku_info + '</div></div></div></td>' +
                                        '<td class="biaoge1-1"><span id="handle_man">' + ss + '</span></td>' +
                                        '<td class="biaoge1-2"><span id="handle_results">' + v.buyyer_count + '' + v.unit_name + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + v.delivery_count + '' + v.unit_name + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + v.receive_count + '' + v.unit_name + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + v.have_returned_count + '' + v.unit_name + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + price + '元/' + v.unit_name + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + newprice + '元/' + v.unit_name + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + couponvalues + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + fares + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + v.promotion_value + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + v.used_points + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + substotle + '元' + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + newsubstotle + '元' + '</span></td>' +
                                        '</tr>';
                                }
                            }

                        }
                    )


                })
            }
            //数量商品
            if (result.fullQuantityReduceOrderItemsMap != "" && result.fullQuantityReduceOrderItemsMap != null) {
                var arr = result.fullQuantityReduceOrderItemsMap
                $.each(arr, function (index, i) {
                    //算出该活动的所有商品小计和优惠值
                    let countMoney = 0;
                    let promotionMoney = 0;
                    $.each(arr[index], function (k, v) {
                        promotionMoney = Number(promotionMoney) + Number(v.promotion_value);
                        countMoney = Number(countMoney) + Number((v.sale_price * v.buyyer_count).toFixed(2));
                    })

                    let ruleStre = '<tr><td colspan="11"><div>' +
                        '<span style="float: left;">' + arr[index][0].activity_rule + '</span>' +
                        '<div style="float: right"><span style="float: left;">￥' + countMoney + '</span><br>' +
                        '<span style="float: left;">减：' + (promotionMoney).toFixed(2) + '</span></div>' +
                        '</div></td></tr>';
                    hdStrdf += ruleStre;

                    $.each(arr[index], function (k, v) {

                            var ss = ""
                            $.each(warehouses.data, function (k, s) {
                                if (result.orderBase.parent_warehouse_id == s.warehouseCode) {
                                    ss = s.warehouseName
                                }
                            })

                            //单价
                            var price = v.init_sale_price

                            var specialPrice = ""
                            if (v.activity_type == 10) {
                                specialPrice = v.promotion_value / v.buyyer_count
                            }
                            price = (price - specialPrice).toFixed(2)
                            //新单价
                            var newprice = v.sale_price
                            var newspecialPrice = ""
                            if (v.activity_type == 10) {
                                newspecialPrice = v.promotion_value / v.buyyer_count
                            }
                            newprice = (newprice - newspecialPrice).toFixed(2)
                            //运费分摊
                            var fares = ""
                            if (result.orderBase.separate_shipping_fee == 10) {
                                fares = "0"
                            } else {
                                fares = v.fare

                            }
                            //满减券分摊
                            var couponvalues = ""
                            if (result.orderCoupon != "" && result.orderCoupon != null) {

                                if (result.orderCoupon.coupon_type == 10) {
                                    couponvalues = v.coupon_value
                                } else {
                                    couponvalues = "0"
                                }
                            }
                            console.log("运费" + fares)
                            //小计
                            var substotle = (price * v.buyyer_count).toFixed(2);
                            //新小计
                            var newsubstotle = (newprice * v.buyyer_count).toFixed(2);

                            if (result.orderBase.change_price == 10) {
                                //未改价过的订单
                                if (v.spu_id == 0) {
                                    hdStrdf += '<tr class="biaoge1">' +
                                        '<td class="biaoge1-1"><div style="cursor:pointer;"><img title="" style="float: left;width: 100px;height: 100px;" name="" src="' + v.product_pic + '" alt=""><div style="float: left;width:180px;padding-top: 20px;margin-left: 10px;"><div>' + v.sku_code + '</div><div>' + v.product_name + '</div><div>' + v.color + '</div><div>' + v.sku_info + '</div></div></div></td>' +
                                        '<td class="biaoge1-1"><span id="handle_man">' + ss + '</span></td>' +
                                        '<td class="biaoge1-2"><span id="handle_results">' + v.buyyer_count + '' + v.unit_name + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + v.delivery_count + '' + v.unit_name + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + v.receive_count + '' + v.unit_name + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + v.have_returned_count + '' + v.unit_name + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + price + '元/' + v.unit_name + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + couponvalues + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + fares + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + v.promotion_value + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + v.used_points + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + substotle + '元' + '</span></td>' +
                                        '</tr>';
                                } else {
                                    hdStrdf += '<tr class="biaoge1">' +
                                        '<td class="biaoge1-1"><div style="cursor:pointer;"><img title="点击跳转sku列表" onclick="goToGoodsDetail(' + v.spu_id + ')"  style="float: left;width: 100px;height: 100px;" name="" src="' + v.product_pic + '" alt=""><div style="float: left;width:180px;padding-top: 20px;margin-left: 10px;"><div>' + v.sku_code + '</div><div>' + v.product_name + '</div><div>' + v.color + '</div><div>' + v.sku_info + '</div></div></div></td>' +
                                        '<td class="biaoge1-1"><span id="handle_man">' + ss + '</span></td>' +
                                        '<td class="biaoge1-2"><span id="handle_results">' + v.buyyer_count + '' + v.unit_name + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + v.delivery_count + '' + v.unit_name + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + v.receive_count + '' + v.unit_name + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + v.have_returned_count + '' + v.unit_name + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + price + '元/' + v.unit_name + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + couponvalues + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + fares + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + v.promotion_value + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + v.used_points + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + substotle + '元' + '</span></td>' +
                                        '</tr>';
                                }
                            } else {
                                //改过价的订单
                                if (v.spu_id == 0) {
                                    hdStrdf += '<tr class="biaoge1">' +
                                        '<td class="biaoge1-1"><div style="cursor:pointer;"><img title="" style="float: left;width: 100px;height: 100px;" name="" src="' + v.product_pic + '" alt=""><div style="float: left;width:180px;padding-top: 20px;margin-left: 10px;"><div>' + v.sku_code + '</div><div>' + v.product_name + '</div><div>' + v.color + '</div><div>' + v.sku_info + '</div></div></div></td>' +
                                        '<td class="biaoge1-1"><span id="handle_man">' + ss + '</span></td>' +
                                        '<td class="biaoge1-2"><span id="handle_results">' + v.buyyer_count + '' + v.unit_name + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + v.delivery_count + '' + v.unit_name + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + v.receive_count + '' + v.unit_name + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + v.have_returned_count + '' + v.unit_name + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + price + '元/' + v.unit_name + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + newprice + '元/' + v.unit_name + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + couponvalues + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + fares + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + v.promotion_value + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + v.used_points + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + substotle + '元' + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + newsubstotle + '元' + '</span></td>' +
                                        '</tr>';
                                } else {
                                    hdStrdf += '<tr class="biaoge1">' +
                                        '<td class="biaoge1-1"><div style="cursor:pointer;"><img title="点击跳转sku列表" onclick="goToGoodsDetail(' + v.spu_id + ')"  style="float: left;width: 100px;height: 100px;" name="" src="' + v.product_pic + '" alt=""><div style="float: left;width:180px;padding-top: 20px;margin-left: 10px;"><div>' + v.sku_code + '</div><div>' + v.product_name + '</div><div>' + v.color + '</div><div>' + v.sku_info + '</div></div></div></td>' +
                                        '<td class="biaoge1-1"><span id="handle_man">' + ss + '</span></td>' +
                                        '<td class="biaoge1-2"><span id="handle_results">' + v.buyyer_count + '' + v.unit_name + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + v.delivery_count + '' + v.unit_name + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + v.receive_count + '' + v.unit_name + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + v.have_returned_count + '' + v.unit_name + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + price + '元/' + v.unit_name + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + newprice + '元/' + v.unit_name + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + couponvalues + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + fares + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + v.promotion_value + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + v.used_points + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + substotle + '元' + '</span></td>' +
                                        '<td class="biaoge1-3"><span id="create_time">' + newsubstotle + '元' + '</span></td>' +
                                        '</tr>';
                                }
                            }

                        }
                    )


                })
            }
            //特价商品
            if (result.specialPriceOrderItemsList != "" && result.specialPriceOrderItemsList != null) {
                var arr = result.specialPriceOrderItemsList

                //算出该活动的所有商品小计和优惠值
                let ii = ""
                let ruleStret = '<tr><td colspan="11"><div>' +
                    '<span style="float: left;">' + ii + '</span>' +
                    /*'<div style="float: right"><span style="float: left;">￥'+countMoney+'</span><br>' +
                        '<span style="float: left;">减：'+promotionMoney+'</span></div>' +*/
                    '</div></td></tr>';
                hdStrdfuu += ruleStret;

                $.each(arr, function (k, v) {
                        var ss = ""
                        $.each(warehouses.data, function (k, s) {
                            if (result.orderBase.parent_warehouse_id == s.warehouseCode) {
                                ss = s.warehouseName
                            }
                        })
                        //单价
                        var price = v.init_sale_price

                        var specialPrice = ""
                        if (v.activity_type == 10) {
                            specialPrice = v.promotion_value / v.buyyer_count
                        }
                        price = (price - specialPrice).toFixed(2)
                        //新单价
                        var newprice = v.sale_price
                        var newspecialPrice = ""
                        if (v.activity_type == 10) {
                            newspecialPrice = v.promotion_value / v.buyyer_count
                        }
                        newprice = (newprice - newspecialPrice).toFixed(2)
                        //运费分摊
                        var fares = ""
                        if (result.orderBase.separate_shipping_fee == 10) {
                            fares = "0"
                        } else {
                            /*if(result.orderCoupon!="" && result.orderCoupon!=null){
                                    if(result.orderCoupon.coupon_type == 10){
                                        fares=v.fare
                                    }else {
                                        fares=(v.fare-v.coupon_value).toFixed(2)
                                    }
                                }else {
                                    fares=v.fare
                                }*/
                            fares = v.fare
                        }
                        //满减券分摊
                        var couponvalues = ""
                        if (result.orderCoupon != "" && result.orderCoupon != null) {

                            if (result.orderCoupon.coupon_type == 10) {
                                couponvalues = v.coupon_value
                            } else {
                                couponvalues = "0"
                            }
                        }
                        //小计
                        var substotle = (price * v.buyyer_count).toFixed(2);
                        //新小计
                        var newsubstotle = (newprice * v.buyyer_count).toFixed(2);
                        if (result.orderBase.change_price == 10) {
                            //未改价过的订单
                            if (v.spu_id == 0) {
                                hdStrdfuu += '<tr class="biaoge1">' +
                                    '<td class="biaoge1-1"><div style="cursor:pointer;"><img title="" style="float: left;width: 100px;height: 100px;" name="" src="' + v.product_pic + '" alt=""><div style="float: left;width:180px;padding-top: 20px;margin-left: 10px;"><div>' + v.sku_code + '</div><div>' + v.product_name + '</div><div>' + v.color + '</div><div>' + v.sku_info + '</div></div></div></td>' +
                                    '<td class="biaoge1-1"><span id="handle_man">' + ss + '</span></td>' +
                                    '<td class="biaoge1-2"><span id="handle_results">' + v.buyyer_count + '' + v.unit_name + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + v.delivery_count + '' + v.unit_name + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + v.receive_count + '' + v.unit_name + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + v.have_returned_count + '' + v.unit_name + '</span></td>' +
                                    '<td class="biaoge1-3"><div><input style="width: 32px;background-color: yellow;" value="特价" readonly="readonly"></div><span id="create_time">' + price + '元/' + v.unit_name + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + couponvalues + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + fares + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + "0" + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + v.used_points + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + substotle + '元' + '</span></td>' +
                                    '</tr>';
                            } else {
                                hdStrdfuu += '<tr class="biaoge1">' +
                                    '<td class="biaoge1-1"><div style="cursor:pointer;"><img title="点击跳转sku列表" onclick="goToGoodsDetail(' + v.spu_id + ')" style="float: left;width: 100px;height: 100px;" name="" src="' + v.product_pic + '" alt=""><div style="float: left;width:180px;padding-top: 20px;margin-left: 10px;"><div>' + v.sku_code + '</div><div>' + v.product_name + '</div><div>' + v.color + '</div><div>' + v.sku_info + '</div></div></div></td>' +
                                    '<td class="biaoge1-1"><span id="handle_man">' + ss + '</span></td>' +
                                    '<td class="biaoge1-2"><span id="handle_results">' + v.buyyer_count + '' + v.unit_name + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + v.delivery_count + '' + v.unit_name + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + v.receive_count + '' + v.unit_name + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + v.have_returned_count + '' + v.unit_name + '</span></td>' +
                                    '<td class="biaoge1-3"><div><input style="width: 32px;background-color: yellow;" value="特价" readonly="readonly"></div><span id="create_time">' + price + '元/' + v.unit_name + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + couponvalues + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + fares + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + "0" + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + v.used_points + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + substotle + '元' + '</span></td>' +
                                    '</tr>';
                            }
                        } else {
                            //改过价的订单
                            if (v.spu_id == 0) {
                                hdStrdfuu += '<tr class="biaoge1">' +
                                    '<td class="biaoge1-1"><div style="cursor:pointer;"><img title="" style="float: left;width: 100px;height: 100px;" name="" src="' + v.product_pic + '" alt=""><div style="float: left;width:180px;padding-top: 20px;margin-left: 10px;"><div>' + v.sku_code + '</div><div>' + v.product_name + '</div><div>' + v.color + '</div><div>' + v.sku_info + '</div></div></div></td>' +
                                    '<td class="biaoge1-1"><span id="handle_man">' + ss + '</span></td>' +
                                    '<td class="biaoge1-2"><span id="handle_results">' + v.buyyer_count + '' + v.unit_name + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + v.delivery_count + '' + v.unit_name + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + v.receive_count + '' + v.unit_name + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + v.have_returned_count + '' + v.unit_name + '</span></td>' +
                                    '<td class="biaoge1-3"><div><input style="width: 32px;background-color: yellow;" value="特价" readonly="readonly"></div><span id="create_time">' + price + '元/' + v.unit_name + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + newprice + '元/' + v.unit_name + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + couponvalues + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + fares + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + "0" + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + v.used_points + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + substotle + '元' + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + newsubstotle + '元' + '</span></td>' +
                                    '</tr>';
                            } else {
                                hdStrdfuu += '<tr class="biaoge1">' +
                                    '<td class="biaoge1-1"><div style="cursor:pointer;"><img title="点击跳转sku列表" onclick="goToGoodsDetail(' + v.spu_id + ')" style="float: left;width: 100px;height: 100px;" name="" src="' + v.product_pic + '" alt=""><div style="float: left;width:180px;padding-top: 20px;margin-left: 10px;"><div>' + v.sku_code + '</div><div>' + v.product_name + '</div><div>' + v.color + '</div><div>' + v.sku_info + '</div></div></div></td>' +
                                    '<td class="biaoge1-1"><span id="handle_man">' + ss + '</span></td>' +
                                    '<td class="biaoge1-2"><span id="handle_results">' + v.buyyer_count + '' + v.unit_name + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + v.delivery_count + '' + v.unit_name + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + v.receive_count + '' + v.unit_name + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + v.have_returned_count + '' + v.unit_name + '</span></td>' +
                                    '<td class="biaoge1-3"><div><input style="width: 32px;background-color: yellow;" value="特价" readonly="readonly"></div><span id="create_time">' + price + '元/' + v.unit_name + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + newprice + '元/' + v.unit_name + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + couponvalues + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + fares + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + "0" + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + v.used_points + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + substotle + '元' + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + newsubstotle + '元' + '</span></td>' +
                                    '</tr>';
                            }
                        }

                    }
                )


            }

            if (result.normalPriceOrderItemsList != "" && result.normalPriceOrderItemsList != null) {
                var arr = result.normalPriceOrderItemsList

                //算出该活动的所有商品小计和优惠值
                let ii = ""
                let ruleStret = '<tr><td colspan="11"><div>' +
                    '<span style="float: left;">' + ii + '</span>' +
                    /*'<div style="float: right"><span style="float: left;">￥'+countMoney+'</span><br>' +
                    '<span style="float: left;">减：'+promotionMoney+'</span></div>' +*/
                    '</div></td></tr>';
                hdSdfuu += ruleStret;

                $.each(arr, function (k, v) {
                        console.log(result.orderBase.parent_warehouse_id)

                        var ss = ""
                        $.each(warehouses.data, function (k, s) {
                            if (result.orderBase.parent_warehouse_id == s.warehouseCode) {
                                ss = s.warehouseName
                            }
                        })
                        //单价
                        var price = v.init_sale_price

                        var specialPrice = ""
                        if (v.activity_type == 10) {
                            specialPrice = v.promotion_value / v.buyyer_count
                        }
                        price = (price - specialPrice).toFixed(2)

                        //新单价
                        var newprice = v.sale_price
                        var newspecialPrice = ""
                        if (v.activity_type == 10) {
                            newspecialPrice = v.promotion_value / v.buyyer_count
                        }
                        newprice = (newprice - newspecialPrice).toFixed(2)
                        //运费分摊
                        var fares = ""
                        if (result.orderBase.separate_shipping_fee == 10) {
                            fares = "0"
                        } else {
                            fares = v.fare

                        }
                        //满减券分摊
                        var couponvalues = ""
                        if (result.orderCoupon != "" && result.orderCoupon != null) {

                            if (result.orderCoupon.coupon_type == 10) {
                                couponvalues = v.coupon_value
                            } else {
                                couponvalues = "0"
                            }
                        }
                        //小计
                        var substotle = (price * v.buyyer_count).toFixed(2);
                        //新小计
                        var newsubstotle = (newprice * v.buyyer_count).toFixed(2);
                        if (result.orderBase.change_price == 10) {
                            //未改价过的订单
                            if (v.spu_id == 0) {
                                hdSdfuu += '<tr class="biaoge1">' +
                                    '<td class="biaoge1-1"><div style="cursor:pointer;"><img title="" style="float: left;width: 100px;height: 100px;" name="" src="' + v.product_pic + '" alt=""><div style="float: left;width:180px;padding-top: 20px;margin-left: 10px;"><div>' + v.sku_code + '</div><div>' + v.product_name + '</div><div>' + v.color + '</div><div>' + v.sku_info + '</div></div></div></td>' +
                                    '<td class="biaoge1-1"><span id="handle_man">' + ss + '</span></td>' +
                                    '<td class="biaoge1-2"><span id="handle_results">' + v.buyyer_count + '' + v.unit_name + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + v.delivery_count + '' + v.unit_name + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + v.receive_count + '' + v.unit_name + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + v.have_returned_count + '' + v.unit_name + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + price + '元/' + v.unit_name + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + couponvalues + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + fares + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + v.promotion_value + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + v.used_points + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + substotle + '元' + '</span></td>' +
                                    '</tr>';
                            } else {
                                hdSdfuu += '<tr class="biaoge1">' +
                                    '<td class="biaoge1-1"><div style="cursor:pointer;"><img title="点击跳转sku列表" onclick="goToGoodsDetail(' + v.spu_id + ')" style="float: left;width: 100px;height: 100px;" name="" src="' + v.product_pic + '" alt=""><div style="float: left;width:180px;padding-top: 20px;margin-left: 10px;"><div>' + v.sku_code + '</div><div>' + v.product_name + '</div><div>' + v.color + '</div><div>' + v.sku_info + '</div></div></div></td>' +
                                    '<td class="biaoge1-1"><span id="handle_man">' + ss + '</span></td>' +
                                    '<td class="biaoge1-2"><span id="handle_results">' + v.buyyer_count + '' + v.unit_name + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + v.delivery_count + '' + v.unit_name + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + v.receive_count + '' + v.unit_name + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + v.have_returned_count + '' + v.unit_name + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + price + '元/' + v.unit_name + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + couponvalues + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + fares + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + v.promotion_value + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + v.used_points + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + substotle + '元' + '</span></td>' +
                                    '</tr>';
                            }
                        } else {
                            //改过价的订单
                            if (v.spu_id == 0) {
                                hdSdfuu += '<tr class="biaoge1">' +
                                    '<td class="biaoge1-1"><div style="cursor:pointer;"><img title="" style="float: left;width: 100px;height: 100px;" name="" src="' + v.product_pic + '" alt=""><div style="float: left;width:180px;padding-top: 20px;margin-left: 10px;"><div>' + v.sku_code + '</div><div>' + v.product_name + '</div><div>' + v.color + '</div><div>' + v.sku_info + '</div></div></div></td>' +
                                    '<td class="biaoge1-1"><span id="handle_man">' + ss + '</span></td>' +
                                    '<td class="biaoge1-2"><span id="handle_results">' + v.buyyer_count + '' + v.unit_name + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + v.delivery_count + '' + v.unit_name + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + v.receive_count + '' + v.unit_name + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + v.have_returned_count + '' + v.unit_name + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + price + '元/' + v.unit_name + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + newprice + '元/' + v.unit_name + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + couponvalues + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + fares + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + v.promotion_value + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + v.used_points + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + substotle + '元' + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + newsubstotle + '元' + '</span></td>' +
                                    '</tr>';
                            } else {
                                hdSdfuu += '<tr class="biaoge1">' +
                                    '<td class="biaoge1-1"><div style="cursor:pointer;"><img title="点击跳转sku列表" onclick="goToGoodsDetail(' + v.spu_id + ')" style="float: left;width: 100px;height: 100px;" name="" src="' + v.product_pic + '" alt=""><div style="float: left;width:180px;padding-top: 20px;margin-left: 10px;"><div>' + v.sku_code + '</div><div>' + v.product_name + '</div><div>' + v.color + '</div><div>' + v.sku_info + '</div></div></div></td>' +
                                    '<td class="biaoge1-1"><span id="handle_man">' + ss + '</span></td>' +
                                    '<td class="biaoge1-2"><span id="handle_results">' + v.buyyer_count + '' + v.unit_name + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + v.delivery_count + '' + v.unit_name + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + v.receive_count + '' + v.unit_name + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + v.have_returned_count + '' + v.unit_name + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + price + '元/' + v.unit_name + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + newprice + '元/' + v.unit_name + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + couponvalues + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + fares + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + v.promotion_value + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + v.used_points + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + substotle + '元' + '</span></td>' +
                                    '<td class="biaoge1-3"><span id="create_time">' + newsubstotle + '元' + '</span></td>' +
                                    '</tr>';
                            }
                        }


                    }
                )


            }
            $("#datatable").find("tbody").append($(handStr));
            $("#datatable").find("tbody").append($(hdStrdf));
            $("#datatable").find("tbody").append($(hdStrdfuu));
            $("#datatable").find("tbody").append($(hdSdfuu));


        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            alert(XMLHttpRequest);
        }
    });
}


/*转换状态函数*/
function changeOrderState(orderState) {
    switch (orderState) {
        /*订单状态*/
        case 9:
            return "待付款";
            break;
        case 10:
            return "待付款";
            break;
        case 20:
            return "待审核";
            break;
        case 30:
            return "待配货";
            break;
        case 40:
            return "待出库";
            break;
        case 50:
            return "待发货";
            break;
        case 60:
            return "待收货";
            break;
        case 70:
            return "已收货，待结算";
            break;
        case 80:
            return "订单成功";
            break;
        case 90:
            return "交易完成";
            break;
        case 100:
            return "已取消";
            break;
        case 110:
            return "交易关闭";
            break;
    }
}

function calculate(listAddressReceiver, type) {
    var math = ""
    var phone = ""
    var he = ""
    var size = listAddressReceiver.length
    if (listAddressReceiver.length == 0) {
        return "";
    }
    for (i = 0; i < size; i++) {
        if (i < size - 1) {
            math += listAddressReceiver[i].receiver_name + " ;"
            phone += listAddressReceiver[i].mobile + " ; "
            if (i % 2 != 0) {
                he += listAddressReceiver[i].receiver_name + listAddressReceiver[i].mobile + " ; <br/> "
                /* he+=listAddressReceiver[i].mobile+" ; <br/> "*/
            } else {
                he += listAddressReceiver[i].receiver_name + listAddressReceiver[i].mobile + " ;  "
                /* he+=listAddressReceiver[i].mobile+" ;  "*/
            }
        } else {
            math += listAddressReceiver[i].receiver_name
            phone += listAddressReceiver[i].mobile
            if (i % 2 != 0) {
                he += listAddressReceiver[i].receiver_name + listAddressReceiver[i].mobile + "  <br/> "
                /*he+=listAddressReceiver[i].mobile+"  <br/> "*/
            } else {
                he += listAddressReceiver[i].receiver_name + listAddressReceiver[i].mobile + "   "
                /*he+=listAddressReceiver[i].mobile+"   "*/
            }
        }
    }
    if (type == 1) {
        return math
    } else if (type == 2) {
        return phone
    } else if (type == 3) {
        return he
    }
}

function changePayTypeState(payTypeState) {
    switch (payTypeState) {
        /*支付方式*/
        case 1001:
            return "在线支付";
            break;
        case 1002:
            return "支付宝支付";
            break;
        case 1003:
            return "微信支付";
            break;
        case 1101:
            return "货到付款";
            break;
        case 1102:
            return "货到付款-现金";
            break;
        case 1103:
            return "货到付款-pos机";
            break;
        case 1201:
            return "账期支付";
            break;
        case 1301:
            return "银行转账";
            break;
        case 1401:
            return "银行汇票";
            break;
    }
}


// function changePayState(payTypeState) {
//     switch(payTypeState) {
//         /*支付方式*/
//         case 1001:
//             return "在线支付";
//             break;
//         case 1002:
//             return "线上支付";
//             break;
//         case 1003:
//             return "线上支付";
//             break;
//         case 1101:
//             return "货到付款";
//             break;
//         case 1201:
//             return "账期支付";
//             break;
//         case 1301:
//             return "银行转账";
//             break;
//         case 1401:
//             return "电子汇票";
//             break;
//     }
// }

function changeDeliveryMethodType(DeliveryMethodType) {
    switch (DeliveryMethodType) {
        /*配送方式*/
        case 10:
            return "鑫方盛物流";
            break;
        case 20:
            return "店内自提";
            break;
    }
}

function changeCopies(is_required, file_copies, original_file) {
    var val
    /*if (is_required==20&&original_file==20){
        val='不需要资质文件'
        return val
    }*/
    if (file_copies == 0) {
        val = '不需要资质文件'
        return val
    }
    /* if (is_required==10){
        val='需要&nbsp;&nbsp;&nbsp;&nbsp;'
    }else if (is_required==20){
        val='不需要&nbsp;&nbsp;&nbsp;&nbsp;'
    }*/
    console.log(file_copies)
    if (file_copies != 0) {
        val = '需要资质文件&nbsp;&nbsp;&nbsp;&nbsp;'
    } else {
        val = '不需要资质文件&nbsp;&nbsp;&nbsp;&nbsp;'
    }
    if (file_copies >= 4) {
        val += 4 + '份&nbsp;&nbsp;&nbsp;&nbsp;'
    } else {
        val += file_copies + '份&nbsp;&nbsp;&nbsp;&nbsp;'
    }

    if (original_file == 10) {
        val += '带红章'
    } else if (original_file == 20) {
        val += '不带红章'
    }
    return val;
}


function changeInvoiceType(invoiceType) {
    switch (invoiceType) {
        /*发票类型*/
        case 10:
            return "增值税";
            break;
        case 20:
            return "普税";
            break;
    }
}

function changeCancleReason(cancleReason) {
    switch (cancleReason) {
        /*取消原因*/
        case 10:
            return "订购错误";
            break;
        case 11:
            return "价格高";
            break;
        case 12:
            return "无法满足到货时效";
            break;
        case 13:
            return "支付问题";
            break;
        case 14:
            return "重复下单";
            break;
        case 15:
            return "暂时不需要";
            break;
        case 16:
            return "订单信息有误";
            break;
        case 17:
            return "无货";
            break;
        case 18:
            return "其他";
            break;
        case 110:
            return "公司产品原因";
            break;
        case 101:
            return "客户原因";
            break;
        case 102:
            return "用户审批驳回取消";
            break;
    }
}

function changeCloseReason(closeReason) {
    switch (closeReason) {
        /*关闭原因*/
        case 10:
            return "商品质量问题";
            break;
        case 20:
            return "大小/型号与商品描述不符";
            break;
        case 30:
            return "颜色/图案与商品描述不符";
            break;
        case 40:
            return "功能/效果与商品描述不符";
            break;
        case 50:
            return "商城发错货";
            break;
        case 60:
            return "少件/漏件";
            break;
        case 70:
            return "多买/买错不想要了";
            break;
        case 80:
            return "到货物流破损";
            break;
        case 90:
            return "发票问题";
            break;
        case 100:
            return "未按约定时间发货";
            break;
        case 110:
            return "其他原因";
            break;
    }
}

/*渲染页面*/

/*头部按钮*/

function affirmMoney() {
    //权限判断3
    var warehouse_ids =sessionStorage.getItem("regions")//主仓库

    var sales_manager_ids = sessionStorage.getItem("personnels")//人员
    var companys_ids=sessionStorage.getItem("companys")//客户归属&分公司

    //都没勾选
    if(warehouse_ids=="" && companys_ids=="") {
        $.Huimodalalert('暂无此订单处理权限！', 2000);
    }
    //只勾选仓
    if(warehouse_ids!="" && companys_ids=="") {

        var warehouse_idsAll=warehouse_ids.split(",");
        var isHas = false;
        for (var i = 0; i < warehouse_idsAll.length; i++) {
            console.log(warehouse_idsAll)
            if (warehouse_idsAll[i]==JSON.parse(sessionStorage.getItem("orderDetail")).orderBase.parent_warehouse_id) {
                /*确认认款*/
                sessionStorage.setItem("memberIds", memberIds)
                sessionStorage.setItem("platforms", platforms)
                /*确认认款*/
                layer_show("确认收款", "affirmMoneyAlert.html", "600", "300");
                isHas = true;
                break;
            }
        }
        if(!isHas){
            $.Huimodalalert('暂无此订单处理权限！', 2000);
        }
    }

    //只勾线分公司
    if(warehouse_ids=="" && companys_ids!="") {
        //有没有勾选分公司
        //子仓库不为空,人员为空时
        if( companys_ids!=""&& sales_manager_ids=="") {

            var companys_idAll=companys_ids.split(",");
            var isHas = false;
            for (var t = 0; t < companys_idAll.length; t++) {
                if ( companys_idAll[t]==JSON.parse(sessionStorage.getItem("orderDetail")).orderExt.belong_groupId) {

                    /*确认认款*/
                    sessionStorage.setItem("memberIds", memberIds)
                    sessionStorage.setItem("platforms", platforms)
                    /*确认认款*/
                    layer_show("确认收款", "affirmMoneyAlert.html", "600", "300");
                    isHas = true;
                    break;
                }

            }
            if(!isHas){
                $.Huimodalalert('暂无此订单处理权限！', 2000);
            }
        }
        //子仓库,人员不为空时
        if( companys_ids!=""&& sales_manager_ids!="") {

            var sales_manager_idsAll=sales_manager_ids.split(",");
            var companys_idAll=companys_ids.split(",");
            var isHas = false;
            for (var j = 0; j < sales_manager_idsAll.length; j++) {
                for (var t = 0; t < companys_idAll.length; t++) {
                    if ( sales_manager_idsAll[j]==JSON.parse(sessionStorage.getItem("orderDetail")).orderExt.sales_manager_id || companys_idAll[t]==JSON.parse(sessionStorage.getItem("orderDetail")).orderExt.belong_groupId){

                        isHas = true;
                        break;

                    }
                }
            }
            if(!isHas){
                $.Huimodalalert('暂无此订单处理权限！', 2000);
            }else {
                /*确认认款*/
                sessionStorage.setItem("memberIds", memberIds)
                sessionStorage.setItem("platforms", platforms)
                /*确认认款*/
                layer_show("确认收款", "affirmMoneyAlert.html", "600", "300");

            }
        }
    }
    //仓和分公司
    if(warehouse_ids!="" && companys_ids!="") {
        //主仓不为空，子仓库不为空,人员为空时
        if(warehouse_ids!="" && companys_ids!=""&& sales_manager_ids=="") {
            var warehouse_idsAll=warehouse_ids.split(",");

            var companys_idAll=companys_ids.split(",");
            var isHas = false;
            for (var d = 0; d < warehouse_idsAll.length; d++) {
                for (var t = 0; t < companys_idAll.length; t++) {
                    if (warehouse_idsAll[d]==JSON.parse(sessionStorage.getItem("orderDetail")).orderBase.parent_warehouse_id  || companys_idAll[t]==JSON.parse(sessionStorage.getItem("orderDetail")).orderExt.belong_groupId) {
                        isHas = true;
                        break;
                    }
                }
            }
            if(!isHas){
                $.Huimodalalert('暂无此订单处理权限！', 2000);
            }else {
                /*确认认款*/
                sessionStorage.setItem("memberIds", memberIds)
                sessionStorage.setItem("platforms", platforms)
                /*确认认款*/
                layer_show("确认收款", "affirmMoneyAlert.html", "600", "300");

            }
        }
        //主仓不为空，子仓库不为空,人员不为空时
        if(warehouse_ids!="" && companys_ids!=""&& sales_manager_ids!="") {
            var warehouse_idsAll=warehouse_ids.split(",");

            var sales_manager_idsAll=sales_manager_ids.split(",");
            var companys_idAll=companys_ids.split(",");
            var isHas = false;
            for (var d = 0; d < warehouse_idsAll.length; d++) {
                for (var f = 0; f < sales_manager_idsAll.length; f++) {
                    for (var t = 0; t < companys_idAll.length; t++) {
                        if (warehouse_idsAll[d]==JSON.parse(sessionStorage.getItem("orderDetail")).orderBase.parent_warehouse_id  || sales_manager_idsAll[f]==JSON.parse(sessionStorage.getItem("orderDetail")).orderExt.sales_manager_id || companys_idAll[t]==JSON.parse(sessionStorage.getItem("orderDetail")).orderExt.belong_groupId) {


                            isHas = true;
                            break;
                        }
                    }
                }
            }
            if(!isHas){
                $.Huimodalalert('暂无此订单处理权限！', 2000);
            }else {
                /*确认认款*/
                sessionStorage.setItem("memberIds", memberIds)
                sessionStorage.setItem("platforms", platforms)
                /*确认认款*/
                layer_show("确认收款", "affirmMoneyAlert.html", "600", "300");
            }
        }

    }



}

/*跳转拒收页面*/
function clientRejection(title, url) {
    //权限判断3
    var warehouse_ids =sessionStorage.getItem("regions")//主仓库

    var sales_manager_ids = sessionStorage.getItem("personnels")//人员
    var companys_ids=sessionStorage.getItem("companys")//客户归属&分公司

    //都没勾选
    if(warehouse_ids=="" && companys_ids=="") {
        $.Huimodalalert('暂无此订单处理权限！', 2000);
    }
    //只勾选仓
    if(warehouse_ids!="" && companys_ids=="") {

        var warehouse_idsAll=warehouse_ids.split(",");
        var isHas = false;
        for (var i = 0; i < warehouse_idsAll.length; i++) {
            console.log(warehouse_idsAll)
            if (warehouse_idsAll[i]==JSON.parse(sessionStorage.getItem("orderDetail")).orderBase.parent_warehouse_id) {
                var index = layer.open({
                    type: 2,
                    title: title,
                    content: url
                });
                layer.full(index);
                isHas = true;
                break;
            }
        }
        if(!isHas){
            $.Huimodalalert('暂无此订单处理权限！', 2000);
        }
    }

    //只勾线分公司
    if(warehouse_ids=="" && companys_ids!="") {
        //有没有勾选分公司
        //子仓库不为空,人员为空时
        if( companys_ids!=""&& sales_manager_ids=="") {

            var companys_idAll=companys_ids.split(",");
            var isHas = false;
            for (var t = 0; t < companys_idAll.length; t++) {
                if ( companys_idAll[t]==JSON.parse(sessionStorage.getItem("orderDetail")).orderExt.belong_groupId) {

                    var index = layer.open({
                        type: 2,
                        title: title,
                        content: url
                    });
                    layer.full(index);
                    isHas = true;
                    break;
                }

            }
            if(!isHas){
                $.Huimodalalert('暂无此订单处理权限！', 2000);
            }
        }
        //子仓库,人员不为空时
        if( companys_ids!=""&& sales_manager_ids!="") {

            var sales_manager_idsAll=sales_manager_ids.split(",");
            var companys_idAll=companys_ids.split(",");
            var isHas = false;
            for (var j = 0; j < sales_manager_idsAll.length; j++) {
                for (var t = 0; t < companys_idAll.length; t++) {
                    if ( sales_manager_idsAll[j]==JSON.parse(sessionStorage.getItem("orderDetail")).orderExt.sales_manager_id || companys_idAll[t]==JSON.parse(sessionStorage.getItem("orderDetail")).orderExt.belong_groupId){

                        isHas = true;
                        break;

                    }
                }
            }
            if(!isHas){
                $.Huimodalalert('暂无此订单处理权限！', 2000);
            }else {
                var index = layer.open({
                    type: 2,
                    title: title,
                    content: url
                });
                layer.full(index);
                isHas = true;


            }
        }
    }
    //仓和分公司
    if(warehouse_ids!="" && companys_ids!="") {
        //主仓不为空，子仓库不为空,人员为空时
        if(warehouse_ids!="" && companys_ids!=""&& sales_manager_ids=="") {
            var warehouse_idsAll=warehouse_ids.split(",");

            var companys_idAll=companys_ids.split(",");
            var isHas = false;
            for (var d = 0; d < warehouse_idsAll.length; d++) {
                for (var t = 0; t < companys_idAll.length; t++) {
                    if (warehouse_idsAll[d]==JSON.parse(sessionStorage.getItem("orderDetail")).orderBase.parent_warehouse_id  || companys_idAll[t]==JSON.parse(sessionStorage.getItem("orderDetail")).orderExt.belong_groupId) {
                        isHas = true;
                        break;
                    }
                }
            }
            if(!isHas){
                $.Huimodalalert('暂无此订单处理权限！', 2000);
            }else {
                var index = layer.open({
                    type: 2,
                    title: title,
                    content: url
                });
                layer.full(index);
                isHas = true;

            }
        }
        //主仓不为空，子仓库不为空,人员不为空时
        if(warehouse_ids!="" && companys_ids!=""&& sales_manager_ids!="") {
            var warehouse_idsAll=warehouse_ids.split(",");

            var sales_manager_idsAll=sales_manager_ids.split(",");
            var companys_idAll=companys_ids.split(",");
            var isHas = false;
            for (var d = 0; d < warehouse_idsAll.length; d++) {
                for (var f = 0; f < sales_manager_idsAll.length; f++) {
                    for (var t = 0; t < companys_idAll.length; t++) {
                        if (warehouse_idsAll[d]==JSON.parse(sessionStorage.getItem("orderDetail")).orderBase.parent_warehouse_id  || sales_manager_idsAll[f]==JSON.parse(sessionStorage.getItem("orderDetail")).orderExt.sales_manager_id || companys_idAll[t]==JSON.parse(sessionStorage.getItem("orderDetail")).orderExt.belong_groupId) {


                            isHas = true;
                            break;
                        }
                    }
                }
            }
            if(!isHas){
                $.Huimodalalert('暂无此订单处理权限！', 2000);
            }else {
                var index = layer.open({
                    type: 2,
                    title: title,
                    content: url
                });
                layer.full(index);
                isHas = true;
            }
        }

    }

}

var isIngReturn = false;

function returnGoods(title) {
    //权限判断3
    var warehouse_ids =sessionStorage.getItem("regions")//主仓库

    var sales_manager_ids = sessionStorage.getItem("personnels")//人员
    var companys_ids=sessionStorage.getItem("companys")//客户归属&分公司

    //都没勾选
    if(warehouse_ids=="" && companys_ids=="") {
        $.Huimodalalert('暂无此订单处理权限！', 2000);
    }
    //只勾选仓
    if(warehouse_ids!="" && companys_ids=="") {

        var warehouse_idsAll=warehouse_ids.split(",");
        var isHas = false;
        for (var i = 0; i < warehouse_idsAll.length; i++) {
            console.log(warehouse_idsAll)
            if (warehouse_idsAll[i]==JSON.parse(sessionStorage.getItem("orderDetail")).orderBase.parent_warehouse_id) {
                if (isIngReturn) {
                    // layer.msg('请求已提交，请勿重复点击！');
                    return false;
                }
                isIngReturn = true;
                getOrderDetail();
                setTimeout(function () {
                    var orderDetail = JSON.parse(sessionStorage.getItem("orderDetail"));
                    var orderState = orderDetail.orderBase.order_status;
                    if (orderState == "70") {
                        var url = "orderSuccess_refund.html";
                    } else if (orderState == "80") {
                        var url = "orderSuccess_refund.html";
                    } else if (orderState == "90") {
                        var url = "orderSuccess_refund.html";
                    }
                    var index = layer.open({
                        type: 2,
                        title: title,
                        content: url
                    });
                    layer.full(index);
                }, 200)
                isHas = true;
                break;
            }
        }
        if(!isHas){
            $.Huimodalalert('暂无此订单处理权限！', 2000);
        }
    }

    //只勾线分公司
    if(warehouse_ids=="" && companys_ids!="") {
        //有没有勾选分公司
        //子仓库不为空,人员为空时
        if( companys_ids!=""&& sales_manager_ids=="") {

            var companys_idAll=companys_ids.split(",");
            var isHas = false;
            for (var t = 0; t < companys_idAll.length; t++) {
                if ( companys_idAll[t]==JSON.parse(sessionStorage.getItem("orderDetail")).orderExt.belong_groupId) {

                    if (isIngReturn) {
                        // layer.msg('请求已提交，请勿重复点击！');
                        return false;
                    }
                    isIngReturn = true;
                    getOrderDetail();
                    setTimeout(function () {
                        var orderDetail = JSON.parse(sessionStorage.getItem("orderDetail"));
                        var orderState = orderDetail.orderBase.order_status;
                        if (orderState == "70") {
                            var url = "orderSuccess_refund.html";
                        } else if (orderState == "80") {
                            var url = "orderSuccess_refund.html";
                        } else if (orderState == "90") {
                            var url = "orderSuccess_refund.html";
                        }
                        var index = layer.open({
                            type: 2,
                            title: title,
                            content: url
                        });
                        layer.full(index);
                    }, 200)
                    isHas = true;
                    break;
                }

            }
            if(!isHas){
                $.Huimodalalert('暂无此订单处理权限！', 2000);
            }
        }
        //子仓库,人员不为空时
        if( companys_ids!=""&& sales_manager_ids!="") {

            var sales_manager_idsAll=sales_manager_ids.split(",");
            var companys_idAll=companys_ids.split(",");
            var isHas = false;
            for (var j = 0; j < sales_manager_idsAll.length; j++) {
                for (var t = 0; t < companys_idAll.length; t++) {
                    if ( sales_manager_idsAll[j]==JSON.parse(sessionStorage.getItem("orderDetail")).orderExt.sales_manager_id || companys_idAll[t]==JSON.parse(sessionStorage.getItem("orderDetail")).orderExt.belong_groupId){

                        isHas = true;
                        break;

                    }
                }
            }
            if(!isHas){
                $.Huimodalalert('暂无此订单处理权限！', 2000);
            }else {
                if (isIngReturn) {
                    // layer.msg('请求已提交，请勿重复点击！');
                    return false;
                }
                isIngReturn = true;
                getOrderDetail();
                setTimeout(function () {
                    var orderDetail = JSON.parse(sessionStorage.getItem("orderDetail"));
                    var orderState = orderDetail.orderBase.order_status;
                    if (orderState == "70") {
                        var url = "orderSuccess_refund.html";
                    } else if (orderState == "80") {
                        var url = "orderSuccess_refund.html";
                    } else if (orderState == "90") {
                        var url = "orderSuccess_refund.html";
                    }
                    var index = layer.open({
                        type: 2,
                        title: title,
                        content: url
                    });
                    layer.full(index);
                }, 200)
                isHas = true;



            }
        }
    }
    //仓和分公司
    if(warehouse_ids!="" && companys_ids!="") {
        //主仓不为空，子仓库不为空,人员为空时
        if(warehouse_ids!="" && companys_ids!=""&& sales_manager_ids=="") {
            var warehouse_idsAll=warehouse_ids.split(",");

            var companys_idAll=companys_ids.split(",");
            var isHas = false;
            for (var d = 0; d < warehouse_idsAll.length; d++) {
                for (var t = 0; t < companys_idAll.length; t++) {
                    if (warehouse_idsAll[d]==JSON.parse(sessionStorage.getItem("orderDetail")).orderBase.parent_warehouse_id  || companys_idAll[t]==JSON.parse(sessionStorage.getItem("orderDetail")).orderExt.belong_groupId) {
                        isHas = true;
                        break;
                    }
                }
            }
            if(!isHas){
                $.Huimodalalert('暂无此订单处理权限！', 2000);
            }else {
                if (isIngReturn) {
                    // layer.msg('请求已提交，请勿重复点击！');
                    return false;
                }
                isIngReturn = true;
                getOrderDetail();
                setTimeout(function () {
                    var orderDetail = JSON.parse(sessionStorage.getItem("orderDetail"));
                    var orderState = orderDetail.orderBase.order_status;
                    if (orderState == "70") {
                        var url = "orderSuccess_refund.html";
                    } else if (orderState == "80") {
                        var url = "orderSuccess_refund.html";
                    } else if (orderState == "90") {
                        var url = "orderSuccess_refund.html";
                    }
                    var index = layer.open({
                        type: 2,
                        title: title,
                        content: url
                    });
                    layer.full(index);
                }, 200)
                isHas = true;


            }
        }
        //主仓不为空，子仓库不为空,人员不为空时
        if(warehouse_ids!="" && companys_ids!=""&& sales_manager_ids!="") {
            var warehouse_idsAll=warehouse_ids.split(",");

            var sales_manager_idsAll=sales_manager_ids.split(",");
            var companys_idAll=companys_ids.split(",");
            var isHas = false;
            for (var d = 0; d < warehouse_idsAll.length; d++) {
                for (var f = 0; f < sales_manager_idsAll.length; f++) {
                    for (var t = 0; t < companys_idAll.length; t++) {
                        if (warehouse_idsAll[d]==JSON.parse(sessionStorage.getItem("orderDetail")).orderBase.parent_warehouse_id  || sales_manager_idsAll[f]==JSON.parse(sessionStorage.getItem("orderDetail")).orderExt.sales_manager_id || companys_idAll[t]==JSON.parse(sessionStorage.getItem("orderDetail")).orderExt.belong_groupId) {


                            isHas = true;
                            break;
                        }
                    }
                }
            }
            if(!isHas){
                $.Huimodalalert('暂无此订单处理权限！', 2000);
            }else {
                if (isIngReturn) {
                    // layer.msg('请求已提交，请勿重复点击！');
                    return false;
                }
                isIngReturn = true;
                getOrderDetail();
                setTimeout(function () {
                    var orderDetail = JSON.parse(sessionStorage.getItem("orderDetail"));
                    var orderState = orderDetail.orderBase.order_status;
                    if (orderState == "70") {
                        var url = "orderSuccess_refund.html";
                    } else if (orderState == "80") {
                        var url = "orderSuccess_refund.html";
                    } else if (orderState == "90") {
                        var url = "orderSuccess_refund.html";
                    }
                    var index = layer.open({
                        type: 2,
                        title: title,
                        content: url
                    });
                    layer.full(index);
                }, 200)
                isHas = true;

            }
        }

    }

}

function detailCancel() {
    //权限判断3
    var warehouse_ids =sessionStorage.getItem("regions")//主仓库

    var sales_manager_ids = sessionStorage.getItem("personnels")//人员
    var companys_ids=sessionStorage.getItem("companys")//客户归属&分公司

    //都没勾选
    if(warehouse_ids=="" && companys_ids=="") {
        $.Huimodalalert('暂无此订单处理权限！', 2000);
    }
    //只勾选仓
    if(warehouse_ids!="" && companys_ids=="") {

        var warehouse_idsAll=warehouse_ids.split(",");
        var isHas = false;
        for (var i = 0; i < warehouse_idsAll.length; i++) {
            console.log(warehouse_idsAll)
            if (warehouse_idsAll[i]==JSON.parse(sessionStorage.getItem("orderDetail")).orderBase.parent_warehouse_id) {
                layer_show("取消订单", "cancleAlert.html", "600", "300");
                isHas = true;
                break;
            }
        }
        if(!isHas){
            $.Huimodalalert('暂无此订单处理权限！', 2000);
        }
    }

    //只勾线分公司
    if(warehouse_ids=="" && companys_ids!="") {
        //有没有勾选分公司
        //子仓库不为空,人员为空时
        if( companys_ids!=""&& sales_manager_ids=="") {

            var companys_idAll=companys_ids.split(",");
            var isHas = false;
            for (var t = 0; t < companys_idAll.length; t++) {
                if ( companys_idAll[t]==JSON.parse(sessionStorage.getItem("orderDetail")).orderExt.belong_groupId) {

                    layer_show("取消订单", "cancleAlert.html", "600", "300");
                    isHas = true;
                    break;
                }

            }
            if(!isHas){
                $.Huimodalalert('暂无此订单处理权限！', 2000);
            }
        }
        //子仓库,人员不为空时
        if( companys_ids!=""&& sales_manager_ids!="") {

            var sales_manager_idsAll=sales_manager_ids.split(",");
            var companys_idAll=companys_ids.split(",");
            var isHas = false;
            for (var j = 0; j < sales_manager_idsAll.length; j++) {
                for (var t = 0; t < companys_idAll.length; t++) {
                    if ( sales_manager_idsAll[j]==JSON.parse(sessionStorage.getItem("orderDetail")).orderExt.sales_manager_id || companys_idAll[t]==JSON.parse(sessionStorage.getItem("orderDetail")).orderExt.belong_groupId){

                        isHas = true;
                        break;

                    }
                }
            }
            if(!isHas){
                $.Huimodalalert('暂无此订单处理权限！', 2000);
            }else {
                layer_show("取消订单", "cancleAlert.html", "600", "300");
                isHas = true;



            }
        }
    }
    //仓和分公司
    if(warehouse_ids!="" && companys_ids!="") {
        //主仓不为空，子仓库不为空,人员为空时
        if(warehouse_ids!="" && companys_ids!=""&& sales_manager_ids=="") {
            var warehouse_idsAll=warehouse_ids.split(",");

            var companys_idAll=companys_ids.split(",");
            var isHas = false;
            for (var d = 0; d < warehouse_idsAll.length; d++) {
                for (var t = 0; t < companys_idAll.length; t++) {
                    if (warehouse_idsAll[d]==JSON.parse(sessionStorage.getItem("orderDetail")).orderBase.parent_warehouse_id  || companys_idAll[t]==JSON.parse(sessionStorage.getItem("orderDetail")).orderExt.belong_groupId) {
                        isHas = true;
                        break;
                    }
                }
            }
            if(!isHas){
                $.Huimodalalert('暂无此订单处理权限！', 2000);
            }else {
                layer_show("取消订单", "cancleAlert.html", "600", "300");
                isHas = true;



            }
        }
        //主仓不为空，子仓库不为空,人员不为空时
        if(warehouse_ids!="" && companys_ids!=""&& sales_manager_ids!="") {
            var warehouse_idsAll=warehouse_ids.split(",");

            var sales_manager_idsAll=sales_manager_ids.split(",");
            var companys_idAll=companys_ids.split(",");
            var isHas = false;
            for (var d = 0; d < warehouse_idsAll.length; d++) {
                for (var f = 0; f < sales_manager_idsAll.length; f++) {
                    for (var t = 0; t < companys_idAll.length; t++) {
                        if (warehouse_idsAll[d]==JSON.parse(sessionStorage.getItem("orderDetail")).orderBase.parent_warehouse_id  || sales_manager_idsAll[f]==JSON.parse(sessionStorage.getItem("orderDetail")).orderExt.sales_manager_id || companys_idAll[t]==JSON.parse(sessionStorage.getItem("orderDetail")).orderExt.belong_groupId) {


                            isHas = true;
                            break;
                        }
                    }
                }
            }
            if(!isHas){
                $.Huimodalalert('暂无此订单处理权限！', 2000);
            }else {
                layer_show("取消订单", "cancleAlert.html", "600", "300");
                isHas = true;

            }
        }

    }



}

/*function buyAgain() {
	window.location.href = "../replaceOrder/replace-order-01.html";
}*/
/*datatable*/
var dataSource = new Array();
//table的数据源
var table; //table对象
dataSource = [];

function renderOrderPage(data) {
    console.log(data)
    /*商品总金额计算*/
    var goodsAmount = 0;
    for (var i = 0; i < data.listOrderItems.length; i++) {
        goodsAmount += Number(data.listOrderItems[i].sale_price) * Number(data.listOrderItems[i].buyyer_count);
    }

    $("#goodsAmount").html(goodsAmount.toFixed(2));
    /*$("#fare").html(data.orderBase.shipping_fee);*/
    $("#orderAmount").html((goodsAmount + data.orderBase.shipping_fee).toFixed(2));
    /*转换状态*/
    var order_status = changeOrderState(data.orderBase.order_status);
    $("#orderState").html(order_status);
if(data.orderBase.order_status==70||data.orderBase.order_status==80||data.orderBase.order_status==90){
    if(data.orderInvoice==null){
        $("#supplementary").css({
            display: "inline"
        })
    }else {
        if(data.orderInvoice.invoice_status==10||data.orderInvoice.invoice_status==20||data.orderInvoice.invoice_status==60){
            $("#supplementary").css({
                display: "inline"
            })
        }else {
            $("#supplementary").css({
                display: "none"
            })
        }

    }

}else {
    $("#supplementary").css({
        display: "none"
    })
}
    if (data.orderCancleApply != null) {
        $("#cancle_reason").html(data.orderCancleApply.cancle_reason);
        if (data.orderCancleApply.cancle_reason == 10) {
            $("#cancle_reason").html('订购错误');
        } else if (data.orderCancleApply.cancle_reason == 11) {
            $("#cancle_reason").html('价格高');
        } else if (data.orderCancleApply.cancle_reason == 12) {
            $("#cancle_reason").html('无法满足到货时效');
        } else if (data.orderCancleApply.cancle_reason == 13) {
            $("#cancle_reason").html('支付问题');
        } else if (data.orderCancleApply.cancle_reason == 14) {
            $("#cancle_reason").html('重复下单');
        } else if (data.orderCancleApply.cancle_reason == 15) {
            $("#cancle_reason").html('暂时不需要了');
        } else if (data.orderCancleApply.cancle_reason == 16) {
            $("#cancle_reason").html('订单信息有误');
        } else if (data.orderCancleApply.cancle_reason == 17) {
            $("#cancle_reason").html('无货');
        } else if (data.orderCancleApply.cancle_reason == 18) {
            $("#cancle_reason").html('其他');
        } else if (data.orderCancleApply.cancle_reason == 90) {
            $("#cancle_reason").html('系统自动取消');
        } else if (data.orderCancleApply.cancle_reason == 100) {
            $("#cancle_reason").html('公司产品原因');
        } else if (data.orderCancleApply.cancle_reason == 101) {
            $("#cancle_reason").html('客户原因');
        } else if (data.orderCancleApply.cancle_reason == 102) {
            $("#cancle_reason").html('用户审批驳回取消');
        }
        $("#order_statue1").html("<span class=\"list\" id='" + data.orderCancleApply.id + "' onclick='dealmodal(" + data.orderCancleApply.id + ")'>驳回</span>")
        $("#order_statue2").html("<span class=\"list\" id='" + data.orderCancleApply.id + "' onclick='dealdemo(" + data.orderCancleApply.id + ")'>跟进</span>")
        /*$("#order_statue3").html("<span class=\"list\" id='"+data.orderCancleApply.id+"' onclick='dealmodaldemo("+data.orderCancleApply.id+")'>退货申请单</span>")*/


    } else {
        $("#cancle_reason").html("");
    }


    $("#orderId").html(data.orderBase.order_id);
    $("#creatOrderTime").html(data.orderBase.created_at);
    if(data.orderExt.platform==20){

        $("#paid_ats").css({
            display: "none"
        })
    }else {
        $("#paid_ats").css({
            display: "inline"
        })
    }

    if(data.orderExt.paid_at!=""&&data.orderExt.paid_at!=null&&data.orderExt.paid_at!="1000-01-01 00:00:00"){
        $("#paid_at").html(data.orderExt.paid_at);
    }else {
        $("#paid_at").html("");
    }

    //备注隐藏
    /*if(data.orderBase.order_status == 10 || data.orderBase.order_status == 50) {
		$(".orderRemark").css({
			display: "none"
		})
	}*/
    //备注反显
    for (var i = 0; i < data.listOrderRemark.length; i++) {
        if (data.listOrderRemark[i].operate_type == 30) {
            if (data.listOrderRemark[i].remark != null) {
                $("#returnReason").html("全部拒收（" + data.listOrderRemark[i].remark + ")")
            } else {
                $("#returnReason").html("全部拒收")
            }
            $("#closeOptioner").html(data.listOrderRemark[i].operate_username);
        } else if (data.listOrderRemark[i].operate_type == 40) {
            $("#closeOptioner").html(data.listOrderRemark[i].operate_username);
            if (data.listOrderRemark[i].remark != null) {
                $("#returnReason").html("全部退货（" + data.listOrderRemark[i].remark + ")");
            } else {
                $("#returnReason").html("全部退货");
            }
            /*$("#closeTime").html(data.listOrderRemark[i].created_at);
            $("#closeOptioner").html(data.listOrderRemark[i].operate_username);
            $("#close-reason").html(changeCloseReason(data.listOrderRemark[i].refund_reason));
            $("#close-info").html(data.listOrderRemark[i].remark);*/
        } else if (data.listOrderRemark[i].operate_type == 50) {
            $("#customServiceRemark").text(data.listOrderRemark[i].remark);//客服备注
        } else if (data.listOrderRemark[i].operate_type == 60) {
            $("#fareSeasonBox").css({
                display: "inline"
            });
            $("#changeFareSeason").text(data.listOrderRemark[i].remark);//运费备注
        } else if (data.listOrderRemark[i].operate_type == 80) {
            $("#daikess").css({
                display: "inline"
            });

            $("#coptgifes").text(data.listOrderRemark[i].remark);//代客下单运费备注
        } else if (data.listOrderRemark[i].operate_type == 70) {
            $("#dafdgikess").css({
                display: "inline"
            });
            $("#coptgvifes").text(data.listOrderRemark[i].remark);//订单运费备注
        } else if (data.listOrderRemark[i].operate_type == 70 || data.listOrderRemark[i].operate_type == 80) {
            $("#dafdgikess").css({
                display: "inline"
            });
            $("#daikess").css({
                display: "inline"
            });

            $("#coptgifes").text(data.listOrderRemark[i].remark);//代客下单运费备注
            $("#coptgvifes").text(data.listOrderRemark[i].remark);//订单运费备注
        }

        if (data.listOrderRemark[i].operate_type == 20) {
            if (data.listOrderRemark[i] == null) {
                $(".orderRemark textarea").val();
            } else {
                $(".orderRemark textarea").val(data.listOrderRemark[i].remark);
            }
        }
        if (data.listOrderRemark[i].operate_type == 10) {
            if (data.listOrderRemark[i] == null) {
                $("#comfirmMoneyRemark").val();
            } else {
                $("#affirmMoney").css({
                    display: "none"
                })
                $("#comfirmMoneyRemark").html(data.listOrderRemark[i].remark);//确认认款备注
            }
        }
    }
    /*是否是异常订单*/
    if (data.orderAnomal == null) {
        $("#abnormalTypeBox").css({
            display: "none"
        })
    } else {
        var abnormalType = "";
        var abnormalTypeArr = [];
        var rowArr = data.orderAnomal.anomal_type.split(',');

        function getAbnormalType(typeCode) {
            switch (typeCode) {
                case "10":
                    return "大额订单";
                    break;
                case "20":
                    return "临采商品订单";
                    break;
                case "30":
                    return "超赊欠额度订单";
                    break;
                case "40":
                    return "货到付款订单";
                    break;
                case  "50":
                    return "代客下单异常订单";
                    break;
                case  "60":
                    return "超卖订单";
                    break;
                case  "70":
                    return "低于成本价订单";
                    break;
                case  "80":
                    return "erp拦截订单";
                    break;
                case  "90":
                    return "经纬度异常";
                    break;
                case  "100":
                    return "分销订单";
                    break;
                case  "110":
                    return "门店付款";
                    break;
                case  "120":
                    return "账期扣额度失败";
                    break;
                case  "130":
                    return "厂家直送订单";
                    break;
                case  "140":
                    return "缺货超4吨/5方";
                    break;
                case  "150":
                    return "预计送达时间晚于期望送达时间";
                    break;
            }
        }

        for (var i = 0; i < rowArr.length; i++) {
            abnormalTypeArr.push(getAbnormalType(rowArr[i]));
        }
        for (var j = 0; j < abnormalTypeArr.length; j++) {
            if (j < abnormalTypeArr.length - 1) {
                abnormalType += abnormalTypeArr[j] + ",";
            } else {
                abnormalType += abnormalTypeArr[j] + "";
            }
        }
        $("#abnormalType").html(abnormalType)
        if(data.orderBase.order_status!=9 && data.orderBase.order_status!=10){
            $("#abnormalTypeBox").css({
                display: "inline"
            });
        }else {
            $("#abnormalTypeBox").css({
                display: "none"
            });
        }


    }
    /*取消订单记录*/
    if (data.orderCancle != null) {
        $("#cancleTime").html(data.orderCancle.created_at);
        $("#optioner").html(data.orderCancle.cancle_name);
        $("#cancle-reason").html(changeCancleReason(data.orderCancle.cancle_reason));
        $("#cancle-info").html(data.orderCancle.cancel_remark);
    }

    /*关闭订单记录*/
    if(data.orderBase.order_split_status==20){
        if(data.orderExt.trade_closed_at=='1000-01-01 00:00:00'){
            $("#closeTime").html("");
        }else {
            $("#closeTime").html(data.orderExt.trade_closed_at);
        }

        $("#close-info").html("拆分订单");
    }else {
        if (data.orderRefund != null) {
            $("#closeTime").html(data.orderRefund.created_at);
            // $("#closeOptioner").html(data.orderRefund.operate_username);
            $("#close-reason").html(changeCloseReason(data.orderRefund.refund_reason));
            $("#close-info").html(data.orderRefund.refund_desc);
        }
    }

    /*基本信息*/
    /*if(data.orderExt.platform==10){
        $("#buyer-name").html(data.orderBase.login_account);
    }else if(data.orderExt.platform==20){
        $("#buyer-name").html(data.orderBase.customer_name);
    }*/
    //客户内部审核状态
    if (data.listOrderVerifyRecord != "" || data.listOrderVerifyRecord != null) {
        ordertoexamine(data.listOrderVerifyRecord)
    }


    $("#buyer-name").html(data.orderBase.customer_name);

    $("#created-order-code").html(data.orderBase.login_account);
    if (data.orderExt.sent_type == 50) {
        $("#alisaAddress").html("");
    } else {
        $("#alisaAddress").html(data.orderExt.receiver_detail_address_alias);
    }

    $("#receiver-address").html(data.orderExt.receiver_province_name + "" + data.orderExt.receiver_city_name + "" + data.orderExt.receiver_area_name + "" + data.orderExt.receiver_town_name + "" + data.orderExt.receiver_detail_address);
    $("#consignee").html(calculate(data.listAddressReceiver, 1));
    $("#contact-way").html(calculate(data.listAddressReceiver, 2));
    //授权收货人
    $("#cell-phone-number").html(calculate(data.listAddressReceiver, 2));
    $("#sales-manager").html(data.orderExt.sales_manager_name + "&nbsp;&nbsp;" + data.orderExt.sales_manager_phone);
    if (data.orderExt.platform == 10) {
        $("#Customeraudit").css({
            display: "none"
        });
        $("#platform").html("普通平台");
    } else if (data.orderExt.platform == 20) {
        $("#Customeraudit").css({
            display: "block"
        });
        $("#platform").html("签约平台");
    }

    $("#contact-phone").html(data.orderExt.sales_manager_phone);
    $("#email").html(data.orderExt.customer_email);

    /*鼠标移出事件*/
    $("#consignee").mouseover(function () {
        $("#mouseBox").show();
        $("#mouseBox").html(calculate(data.listAddressReceiver, 1));
    }).mouseout(function () {
        $("#mouseBox").hide();
    })
    $("#cell-phone-number").mouseover(function () {
        $("#mouseBoxTwo").show();
        $("#mouseBoxTwo").html(calculate(data.listAddressReceiver, 3))
    }).mouseout(function () {
        $("#mouseBoxTwo").hide();
    })
    //固话
    $("#linePhone").html(data.orderExt.customer_landline_phone);
    if (data.orderBase.role_name == " ") {
        $("#replaceBox").hide();
    } else {
        if(data.orderExt.source==50||data.orderExt.source==60){
            $("#replace-man").html(data.orderBase.role_name);
        }else {
            $("#replace-man").html("");
        }

    }
    var oop=""
    if(data.orderExt.lat==""&& data.orderExt.lat==null){
        oop=data.orderExt.lng
    }else if(data.orderExt.lng==""&&data.orderExt.lng==null){
        oop=data.orderExt.lat
    }else if(data.orderExt.lng==""||data.orderExt.lng==null &&data.orderExt.lat==""|| data.orderExt.lat==null){
        oop=""
    }else {
        oop=data.orderExt.lng+','+data.orderExt.lat
    }
    $("#lng").html(oop);
    /*支付与配送方式*/
    $("#pay-type").html(data.initPayWay);
    $("#delivery-method").html(data.orderExt.sent_type);
    if (data.orderExt.sent_type == 10) {
        $("#delivery-method").html('快递')
    } else if (data.orderExt.sent_type == 20) {
        $("#delivery-method").html('快运-送货上门')
    } else if (data.orderExt.sent_type == 21) {
        $("#delivery-method").html('快运-站点自提')
    } else if (data.orderExt.sent_type == 30) {
        $("#delivery-method").html('专车包车')
    } else if (data.orderExt.sent_type == 40) {
        $("#delivery-method").html('鑫方盛物流')
    } else if (data.orderExt.sent_type == 50) {
        $("#delivery-method").html('上门自提')
    }else if (data.orderExt.sent_type == 52) {
        $("#delivery-method").html('配送客户自提')
    }
    //上门自提
    $("#self_take_in").html(data.self_take_in_str);
    $("#self_take_shop").html(data.orderExt.self_take_shop);
    $("#receiver_detail_address").html(data.orderExt.receiver_province_name + data.orderExt.receiver_city_name + data.orderExt.receiver_detail_address);
    $("#self_take_phone").html(data.orderExt.self_take_phone);
    if (data.orderWarning != "" && data.orderWarning != null) {
        /* if(data.orderWarning.relieve_role==10){
            $("#relieve_role").html("客服");
        }else {
            $("#relieve_role").html("系统");
        }*/
        $("#relieve_role").html(data.orderWarning.login_account);
        $("#operated_at").html(data.orderWarning.operated_at);
    }

    if (data.orderInvoice != "" && data.orderInvoice != null) {
        if(data.orderInvoice.invoice_remark!=""&&data.orderInvoice.invoice_remark!=null){
            $("#invoiceremark").html(data.orderInvoice.invoice_remark);
        }else {
            $("#invoiceremark").html("无");
        }

    }else {
        $("#invoiceremark").html("无");
    }

    /* $("#final_sent").val(data.orderExt.final_sent_type)*/
    //运费
    $("#shippingfee").html((data.orderBase.init_shipping_fee).toFixed(2));
    var yunf = ""
    if (data.orderCoupon != "") {
        if (data.orderBase.used_coupon == 10 && data.orderCoupon.coupon_type == 20) {
            if (data.orderBase.separate_shipping_fee == 10) {
                yunf = (data.orderBase.shipping_fee - data.orderCoupon.coupon_real_value).toFixed(2) + '元' + '&nbsp;&nbsp;' + "(运费单开)"
            } else {
                yunf = "0.00" + '元' + '&nbsp;&nbsp;' + "(运费分摊)"
            }

        } else {
            if (data.orderBase.separate_shipping_fee == 10) {
                yunf = (data.orderBase.shipping_fee).toFixed(2) + '元' + '&nbsp;&nbsp;' + "(运费单开)"
            } else {
                yunf = "0.00" + '元' + '&nbsp;&nbsp;' + "(运费分摊)"
            }

        }
    }


    $("#couponrealvalue").html(yunf);

    $("#freight").html((data.orderBase.shipping_fee).toFixed(2));

    $("#appointment-time").html(data.orderExt.wanna_arrived_in);
    if (data.orderExt.wanna_arrived_in == '1000-01-01 00:00:00') {
        $("#appointment-time").html("");
    } else if (data.orderExt.wanna_arrived_in == null) {

        $("#appointment-time").html("");
    } else {
        $("#appointment-time").html(data.orderExt.wanna_arrived_in);

    }

    //预计送达时间
    if (data.orderExt.order_type == 50) {
        $("#predixt-delivery-time").html(data.orderExt.wanna_arrived_in);
        if (data.orderExt.wanna_arrived_in == '1000-01-01 00:00:00') {
            $("#predixt-delivery-time").html("");
        } else if (data.orderExt.wanna_arrived_in == null) {

            $("#predixt-delivery-time").html("");
        } else {
            $("#predixt-delivery-time").html(data.orderExt.wanna_arrived_in);

        }
    } else {
        $("#predixt-delivery-time").html(data.may_arrived);
        if (data.orderExt.may_arrived_in == '1000-01-01 00:00:00') {
            $("#predixt-delivery-time").html("");
        } else if (data.may_arrived == null) {

            $("#predixt-delivery-time").html("");
        } else {
            $("#predixt-delivery-time").html(data.may_arrived);

        }
    }


    //期望送达时间
    if (data.orderExt.order_type == 50) {
        $("#wanna_arrived_in").html(data.orderExt.wanna_arrived_in);
        if (data.orderExt.wanna_arrived_in == '1000-01-01 00:00:00') {
            $("#wanna_arrived_in").html("");
        } else if (data.orderExt.wanna_arrived_in == null) {

            $("#wanna_arrived_in").html("");
        } else {
            $("#wanna_arrived_in").html(data.orderExt.wanna_arrived_in);
        }
    } else {
        $("#wanna_arrived_in").html(data.wanna_arrived);
        if (data.wanna_arrived == '1000-01-01 00:00:00') {
            $("#wanna_arrived_in").html("");
        } else if (data.wanna_arrived == null) {

            $("#wanna_arrived_in").html("");
        } else {
            $("#wanna_arrived_in").html(data.wanna_arrived);
        }
    }

    //DC仓发货人
    if (data.orderExt.express_company == null) {
        $("#express_company").val("")
    } else {
        /*$("#express_company").val(data.orderExt.express_company+data.orderExt.express_num);*/
        $("#express_company").val(data.orderExt.express_num)
    }
    //快递公司
    if (data.orderExt.express_company == null) {
        $("#express_company2").val("")
    } else {
        $("#express_company2").val(data.orderExt.express_company);
    }
    //询价单号
    $("#inquiry_num").html(data.inquiry_num)
    //快递单号
    if (data.orderExt.express_num == null) {
        $("#express_num").val("")
    } else {
        console.log(data.orderExt.express_num)
        $("#express_num").val(data.orderExt.express_num);
    }
    //实际配送方式
    /* if (data.orderExt.final_sent_type==null){
        $("#final_sent ").val("-1")
    }
    else {
        $("#final_sent ").val(data.orderExt.final_sent_type);
    }*/


    if (data.orderBase.order_status == 9 || data.orderBase.order_status == 10 || data.orderBase.order_status == 20 || data.orderBase.order_status == 30 || data.orderBase.order_status == 40 || data.orderBase.order_status == 50) {

        $("#final_sent option:selected").val("")
    } else {
        $("#final_sent").val(data.orderExt.final_sent_type);
    }


    //快运公司
    if (data.orderExt.express_company == null) {
        $("#express_company3").val("")
    } else {
        console.log(data.orderExt.express_company)
        $("#express_company3").val(data.orderExt.express_company);
    }
    //快运单号
    if (data.orderExt.express_num == null) {
        $("#express_num3").val("")
    } else {
        console.log(data.orderExt.express_num)
        $("#express_num3").val(data.orderExt.express_num);
    }


    //结算金额
    $("#settlement-amount").html(data.orderBase.paid_amount);
    //付款方式
    $("#money-type").html(data.payWay);

    //结算方式
    $("#settlement-method").html(data.settleWay);

    //司机名称和电话
    /*if (data.orderBase.order_status==60){
        $("#driver-phone").val(data.orderExt.express_company);
    }else {
        $("#driver-phone").val(data.orderExt.driver_name + data.orderExt.driver_phone);

    }*/
    if (data.orderExt.final_sent_type == 40 || data.orderBase.order_status != 60) {
        $("#driver-phone").val(data.orderExt.driver_name + data.orderExt.driver_phone);
    } else {
        $("#driver-phone").val(data.orderExt.express_company);

    }

    //配送员名称和电话
    /*if (data.orderBase.order_status==60 || data.orderExt.final_sent_type!=40){
        $("#distributor-phone").val(data.orderExt.express_num);
    }else {
        $("#distributor-phone").val(data.orderExt.deliver_name + data.orderExt.deliver_phone);

    }*/
    if (data.orderExt.final_sent_type == 40 || data.orderBase.order_status != 60) {
        $("#distributor-phone").val(data.orderExt.deliver_name + data.orderExt.deliver_phone);
    } else {
        $("#distributor-phone").val(data.orderExt.express_num);

    }
    //开票状态判断
    if(data.orderInvoice==null){
        $('#invoicetype').text('未开');
    }else{
        if(data.orderInvoice.invoice_status==10||data.orderInvoice.invoice_status==20||data.orderInvoice.invoice_status==60){
            $('#invoicetype').text('未开');
        }else if(data.orderInvoice.invoice_status==30){
            $('#invoicetype').text('部分开');
        }else if(data.orderInvoice.invoice_status==40||data.orderInvoice.invoice_status==50){
            $('#invoicetype').text('已开');
        }
    }
    /*发票信息*/
    if (data.orderInvoice != null) {

        /*if(data.orderInvoice.invoice_type==null ||data.orderInvoice.invoice_type==''){
            $("#invoice-type").html("不开发票")
        }
        if(data.orderInvoice.invoice_type==20 || data.orderInvoice.invoice_title=='个人'){
            $("#invoice-type").html('普通发票'+'&nbsp;&nbsp;'+data.orderInvoice.invoice_title)
        }else if(data.orderInvoice.invoice_type==20 || data.orderInvoice.invoice_title=='鑫方盛~'){
            $("#invoice-type").html('普通发票'+'&nbsp;&nbsp;'+data.orderInvoice.invoice_title+data.orderInvoice.taxpayer_identify_num)
        }else if(data.orderInvoice.invoice_type==10 ){
            $("#invoice-type").html('增值税专用发票'+'&nbsp;&nbsp;'+data.orderInvoice.invoice_title+'&nbsp;&nbsp;'+data.orderInvoice.taxpayer_identify_num+'&nbsp;&nbsp;'+data.orderInvoice.register_address+'&nbsp;&nbsp;'+data.orderInvoice.register_phone+'&nbsp;&nbsp;'+data.orderInvoice.open_bank+'&nbsp;&nbsp;'+data.orderInvoice.bank_account)
        }*/
        if (data.orderInvoice.invoice_type == null || data.orderInvoice.invoice_type == '') {
            $("#invoice-type").html("不开发票")
        }
        if (data.orderInvoice.invoice_type == 20 && data.orderInvoice.invoice_title == '个人') {
            $("#invoice-type").html('普通发票' + '&nbsp;&nbsp;' + data.orderInvoice.invoice_title)
        } else {
            $("#invoice-type").html('普通发票')
            $("#invoice_title").html(data.orderInvoice.invoice_title)
            $("#taxpayer_identify_num").html(data.orderInvoice.taxpayer_identify_num)
        }
        if (data.orderInvoice.invoice_type == 10) {
            $("#invoice-type").html('增值税专用发票')
            $("#invoice_title").html(data.orderInvoice.invoice_title)
            $("#taxpayer_identify_num").html(data.orderInvoice.taxpayer_identify_num)
            $("#register_address").html(data.orderInvoice.register_address)
            $("#register_phone").html(data.orderInvoice.register_phone)
            $("#open_bank").html(data.orderInvoice.open_bank)
            $("#bank_account").html(data.orderInvoice.bank_account)
        }
        $("#invoice-title").html(data.orderInvoice.invoice_title);
        $("#invoice-content").html(data.orderInvoice.invoice_content);

        $("#invoice-title").html(data.orderInvoice.invoice_title);
        $("#invoice-content").html(data.orderInvoice.invoice_content);
    } else {
        $("#invoice-type").html("不开发票")
    }
    /*优惠券信息*/
    if (data.orderCoupon == null) {
        $("#couponInfo").html("无")
    } else {
        $("#couponInfo").html("满" + data.orderCoupon.use_condition + "元减" + data.orderCoupon.coupon_value + "元")
    }
    if (data.orderCoupon == null) {
        $("#couponInfsfo").html("无")
    } else {
        $("#couponInfsfo").html("满" + data.orderCoupon.use_condition + "元减" + data.orderCoupon.coupon_value + "元")
    }

    /*退款信息*/
    /*//对应后台最终退款总金额
    $("#returnMoney").html(data.orderBase.refund_amount_final);
    // 对应后台最终退款总金额
    $("#shouldReturn").html(data.orderBase.refund_amount_final);
    // 对应客户名称
    $("#conpany").html(data.orderBase.customer_name);
    // 对应退款单创建时间
    $("#return-askFor-time").html(data.orderBase.created_at);
    //对应订单关闭时间
    $("#return-finish-time").html(data.orderBase.close_time);
    // 退款备注
    $("#return-remark").html(data.orderBase.close_desc);*/


    $("#longestside").html(data.max_edge + 'm')
    if (data.total_volume < 0.01) {
        $("#volume").html("小于0.01m³")
    } else {
        $("#volume").html(data.total_volume + 'm³')
    }

    $("#weight").html(data.total_weight + 'kg')

    var goodsAmount2=0
    /*结算信息*/
    if (data.orderBase.separate_shipping_fee == 10) {
        //之前计算
        /* $("#goodsAmount").html((data.orderBase.final_total_amount - data.orderBase.shipping_fee - (data.total_promotion_value - data.full_amount_reduce_value - data.full_quantity_reduce_value)).toFixed(2)); //商品金额*/
        //更改之后
        for(var i = 0; i < data.listOrderItems.length; i++) {
            var vipjia=""
            if(data.listOrderItems[i].activity_type==10){
                vipjia=(data.listOrderItems[i].sale_price-data.listOrderItems[i].promotion_value/data.listOrderItems[i].buyyer_count).toFixed(2)
            }else {
                vipjia= (data.listOrderItems[i].sale_price).toFixed(2)
            }
            goodsAmount2 += Number((Number(vipjia) * Number(data.listOrderItems[i].buyyer_count)).toFixed(2))
        }
        $("#goodsAmount").html( goodsAmount2.toFixed(2)); //商品金额
        $("#fare").html((data.orderBase.shipping_fee).toFixed(2)); //运费
    } else {
        //之前计算
        /*
                $("#goodsAmount").html((data.orderBase.final_total_afullAmountReduceOrderItemsMapmount - data.orderBase.shipping_fee - (data.total_promotion_value - data.full_amount_reduce_value - data.full_quantity_reduce_value) + data.orderBase.shipping_fee).toFixed(2)); //商品金额
        */
        //更改之后
        for(var i = 0; i < data.listOrderItems.length; i++) {
            var vipjia=""
            if(data.listOrderItems[i].activity_type==10){
                vipjia=(data.listOrderItems[i].sale_price-data.listOrderItems[i].promotion_value/data.listOrderItems[i].buyyer_count).toFixed(2)
            }else {
                vipjia= (data.listOrderItems[i].sale_price).toFixed(2)
            }
            goodsAmount2 += Number((Number(vipjia) * Number(data.listOrderItems[i].buyyer_count)).toFixed(2))
        }
        $("#goodsAmount").html( (goodsAmount2+data.orderBase.shipping_fee).toFixed(2)); //商品金额
        $("#fare").html("0.00"); //运费
    }

    if (data.orderCoupon != null && data.orderCoupon.coupon_type == 10) {
        var aaa = 0;
        $("#littleFare").html(aaa.toFixed(2)); //运费减免
        if (data.orderCoupon == null) {
            $("#conMoney").html(aaa.toFixed(2)); //优惠券
        } else {
            $("#conMoney").html((data.orderCoupon.coupon_real_value).toFixed(2)); //优惠券
        }
    } else {
        var aaa = 0;
        $("#conMoney").html(aaa.toFixed(2)); //优惠券
        if (data.orderCoupon == null) {
            $("#littleFare").html(aaa.toFixed(2)); //运费减免
        } else {
            $("#littleFare").html((data.orderCoupon.coupon_real_value).toFixed(2)); //运费减免
        }
    }
    //促销立减

    /*   var promnMoney = 0;
    if(data.fullAmountReduceOrderItemsMap!=""){
    var arr=data.fullAmountReduceOrderItemsMap//满金额
    $.each(arr,function (index,i) {
        $.each(arr[index], function (k, v) {

            promnMoney = Number(promnMoney) + Number(v.promotion_value);
        })
    })
    }
    var promnMoneydghh = 0;
    if(data.fullQuantityReduceOrderItemsMap!=""){
    var aff=data.fullQuantityReduceOrderItemsMap//满数量
    $.each(aff,function (index,i) {
        $.each(aff[index], function (k, v) {

            promnMoneydghh = Number(promnMoneydghh) + Number(v.promotion_value);
        })
    })}*/
    $("#cuxiao").html((data.full_amount_reduce_value + data.full_quantity_reduce_value).toFixed(2));
    var used_total_points = ""
    if (data.orderBase.used_total_points != null) {

        used_total_points = (data.orderBase.used_total_points).toFixed(2)

    } else {
        used_total_points = "0.00"
    }
    $("#integral").html(used_total_points);
    $("#orderAmount").html((data.orderBase.paid_amount).toFixed(2)); //订单金额

    /*资质文件信息*/
    $("#copies").html(changeCopies(data.orderBase.quality_file_required, data.orderExt.file_copies, data.orderExt.original_file));
    /*商品信息*/

}

//客户内部审核状态


function ordertoexamine(data) {
    var verifystatus = ""//审核状态
    var orderAccounts = ""//下单账号
    var verifyAccounts = ""//审核账号
    var verifyPhones = ""//审核手机号
    var verifyAccountsOrder = ""//审核顺序
    var verifyAccountsState = ""//审核状态
    var verifyAccountsTime = ""//审核时间
    var settleAccounts = ""//结算账号
    var settleAccountsTime = ""//下单时间
    var orderAccountArr = [];//下单账号数组
    var verifyAccountArr = [];//审批账号数组
    var settleAccountArr = [];//结算账号数组
    for (var i = 0; i < data.length; i++) {
        if (data[i].account_type == 10) {
            verifyAccountArr.push(data[i])
        } else if (data[i].account_type == 20) {
            settleAccountArr.push(data[i])
        } else if (data[i].account_type == 30) {
            orderAccountArr.push(data[i])
        }
    }
    var verifyAccounttable = ""
    if (verifyAccountArr && verifyAccountArr.length > 0) {

        for (var i = 0; i < verifyAccountArr.length; i++) {
            if (verifyAccountArr[i].verify_status == 0) {
                verifystatus = '未审核' + '<i class="toexamine1"></i>'
            } else if (verifyAccountArr[i].verify_status == 10) {
                verifystatus = "审核通过" + '<i class="toexamine2"></i>'
            } else {
                verifystatus = "审核失败" + '<i class="toexamine3"></i>'
            }
            //审核


            verifyAccounts = verifyAccountArr[i].login_account
            verifyPhones=verifyAccountArr[i].telephone//手机号
            //审核顺序
            if (verifyAccountArr[i].approve_seq == 0) {
                verifyAccountsOrder = "否"
            } else {
                verifyAccountsOrder = verifyAccountArr[i].approve_seq
            }
            //审核状态
            verifyAccountsState = verifystatus
            //审核时间
            if (verifyAccountArr[i].verify_status == 10 && verifyAccountArr[i].operated_at == "1000-01-01 00:00:00") {
                verifyAccountsTime = verifyAccountArr[i].created_at
            } else if (verifyAccountArr[i].verify_status == 10 && verifyAccountArr[i].operated_at != "1000-01-01 00:00:00") {
                verifyAccountsTime = verifyAccountArr[i].operated_at
            } else if (verifyAccountArr[i].verify_status == 0 && verifyAccountArr[i].operated_at == "1000-01-01 00:00:00") {
                verifyAccountsTime = ""
            } else if (verifyAccountArr[i].verify_status == 20) {
                verifyAccountsTime = verifyAccountArr[i].operated_at
            } else {
                verifyAccountsTime = ""
            }

            verifyAccounttable += '<tr>' +
                '                            <td class="orderAccount"></td>' +
                '                            <td class="orderPhone"></td>' +
                '                               <td class="verifyAccount">' + verifyAccounts + '</td>' +
                '                               <td class="verifyPhone">'+verifyPhones+'</td>' +
                '                               <td class="verifyAccountOrder">' + verifyAccountsOrder + '</td>' +
                '                               <td class="verifyAccountState">' + verifyAccountsState + '</td>' +
                '                               <td class="verifyAccountTime">' + verifyAccountsTime + '</td>' +
                '                                     <td class="settleAccount"></td>' +
                '                                     <td class="settlePhone"></td>' +
                '                                     <td class="settleAccountTime"></td>' +
                '                    </tr>'


        }
        $(".toexamine").html(verifyAccounttable);
        //下单
        for (var i = 0; i < orderAccountArr.length; i++) {
            $($(".toexamine").find("tr")[i]).find(".orderAccount").html(orderAccountArr[i].login_account)
            $($(".toexamine").find("tr")[i]).find(".orderPhone").html(orderAccountArr[i].telephone)//手机号

        }
        //结算
        for (var i = 0; i < settleAccountArr.length; i++) {


            if (settleAccountArr[i].verify_status == 10 && settleAccountArr[i].operated_at == "1000-01-01 00:00:00") {
                settleAccountsTime = settleAccountArr[i].created_at
            } else if (settleAccountArr[i].verify_status == 10 && settleAccountArr[i].operated_at != "1000-01-01 00:00:00") {
                settleAccountsTime = settleAccountArr[i].operated_at
            } else if (settleAccountArr[i].verify_status == 0 && settleAccountArr[i].operated_at == "1000-01-01 00:00:00") {
                settleAccountsTime = ""
            } else if (settleAccountArr[i].verify_status == 20) {
                settleAccountsTime = settleAccountArr[i].operated_at
            } else {
                settleAccountsTime = ""
            }

            $($(".toexamine").find("tr")[i]).find(".settleAccount").html(settleAccountArr[i].login_account)
            $($(".toexamine").find("tr")[i]).find(".settlePhone").html(settleAccountArr[i].telephone)//手机号
            $($(".toexamine").find("tr")[i]).find(".settleAccountTime").html(settleAccountsTime)
        }
    } else {
        //下单
        for (var i = 0; i < orderAccountArr.length; i++) {
            verifyAccounttable += '<tr>' +
                '                            <td class="orderAccount">' + orderAccountArr[i].login_account + '</td>' +
                '                            <td class="orderPhone">'+orderAccountArr[i].telephone+'</td>' +
                '                               <td class="verifyAccount"></td>' +
                '                               <td class="verifyPhone"></td>' +
                '                               <td class="verifyAccountOrder"></td>' +
                '                               <td class="verifyAccountState"></td>' +
                '                               <td class="verifyAccountTime"></td>' +
                '                                     <td class="settleAccount"></td>' +
                '                                     <td class="settlePhone"></td>' +
                '                                     <td class="settleAccountTime"></td>' +
                '                    </tr>'
        }
        //结算
        console.log(settleAccountArr)
        $(".toexamine").html(verifyAccounttable);
        for (var i = 0; i < settleAccountArr.length; i++) {

            if (settleAccountArr[i].verify_status == 10 && settleAccountArr[i].operated_at == "1000-01-01 00:00:00") {
                settleAccountsTime = settleAccountArr[i].created_at
            } else if (settleAccountArr[i].verify_status == 10 && settleAccountArr[i].operated_at != "1000-01-01 00:00:00") {
                settleAccountsTime = settleAccountArr[i].operated_at
            } else if (settleAccountArr[i].verify_status == 0 && settleAccountArr[i].operated_at == "1000-01-01 00:00:00") {
                settleAccountsTime = ""
            } else if (settleAccountArr[i].verify_status == 20) {
                settleAccountsTime = settleAccountArr[i].operated_at
            } else {
                settleAccountsTime = ""
            }

            $($(".toexamine").find("tr")[i]).find(".settleAccount").html(settleAccountArr[i].login_account)
            $($(".toexamine").find("tr")[i]).find(".settlePhone").html(settleAccountArr[i].telephone)//手机号
            $($(".toexamine").find("tr")[i]).find(".settleAccountTime").html(settleAccountsTime)
        }


        /* $(".toexamine").html(verifyAccounttable);*/

    }
}
/*跳转退货订单详情*/
function returnOrderInfo(title, url, returnId, orderId) {
    sessionStorage.setItem("returnId", returnId);
    sessionStorage.setItem("returnOrderId", orderId);
    var index = layer.open({
        type: 2,
        title: title,
        content: url,
        /* 关闭弹出框的回调函数*/
        end:function () {
            location.replace(location.href)
        }
    });
    layer.full(index);
}

/*订单备注编辑*/
var oldVal = "";

function toEdit() {
    oldVal = $(".orderRemark textarea").val();
    $("#isSaveFalse").css({
        display: "none"
    });
    $("#isSaveTrue").css({
        display: "block"
    });
    $(".orderRemark textarea").removeAttr("readonly");
}

function toCancle() {
    $(".orderRemark textarea").val(oldVal);
    $("#isSaveFalse").css({
        display: "block"
    });
    $("#isSaveTrue").css({
        display: "none"
    });
    $(".orderRemark textarea").css({
        border: "1px #ddd solid"
    });
    $(".errorMsg").css({
        display: "none"
    });
    $(".orderRemark textarea").attr("readonly", "readonly");
}

function remarkToSave() {
    if ($(".orderRemark textarea").val().length > 500) {
        $(".orderRemark textarea").css({
            border: "1px red solid"
        });
        $(".errorMsg").css({
            display: "inline"
        });

    } else {
        $(".orderRemark textarea").css({
            border: "1px #ddd solid"
        });
        $(".errorMsg").css({
            display: "none"
        });
        var orderDetail = JSON.parse(sessionStorage.getItem("orderDetail"));
        var orderState = orderDetail.orderBase.order_status;

        function btnDisplay() {
            $("#isSaveFalse").css({
                display: "block"
            });
            $("#isSaveTrue").css({
                display: "none"
            });
            $(".orderRemark textarea").attr("readonly", "readonly");
        }
        /*进行添加备注请求*/
        btnDisplay();
        $.ajax({
            contentType: "application/json",
            type: "POST",
            url: root.orderInter.order_saveOrderRemark,
            cache: false, //禁用缓存
            dataType: "json",
            data: JSON.stringify({
                bus_id: orderDetail.orderBase.order_id,
                operate_userid: JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.user_ID,
                operate_username: JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.name,
                remark: $("#comfirmRemark").val(),
                "frist_remark_name":JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.name

            }),
            success: function (result) {
                location.replace(location.href);
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                alert(XMLHttpRequest);
            }
        });
    }
}

/*详细信息编辑*/
function requireUpdataInter(updataData) {
    $.ajax({
        contentType: "application/json",
        type: "POST",
        url: root.orderInter.order_edit,
        cache: false, //禁用缓存
        dataType: "json",
        data: updataData,
        success: function (result) {
            if (result.code == 0) {
                $("#addressInpBox").css({
                    display: "none",
                });
                location.replace(location.href);
            }
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            alert(XMLHttpRequest);
        }
    });
}

function updataDisplay(ids) {
    $(ids).css({
        display: "block",
    });
}

function updataSure(val) {
    var orderDetail = JSON.parse(sessionStorage.getItem("orderDetail"));
    switch (val) {
        /*修改那个标签*/
        case "#addressInp":
            /*收货地址*/
            var updataData = JSON.stringify({
                order_id: orderDetail.orderBase.order_id,
                receiver_detail_address: $('#addressInp').val(),
            });
            requireUpdataInter(updataData);
            break;
        case "#consigneeInp":
            /*收货人*/
            var updataData = JSON.stringify({
                order_id: orderDetail.orderBase.order_id,
                received_name: $('#consigneeInp').val(),
            });
            requireUpdataInter(updataData);
            break;

        case "#alisaAddressInp":
            /*地址别名*/
            var updataData = JSON.stringify({
                order_id: orderDetail.orderBase.order_id,
                receiver_detail_address_alias: $('#alisaAddressInp').val(),
            });
            requireUpdataInter(updataData);
            break;
        case "#emailInp":
            /*邮箱*/
            var updataData = JSON.stringify({
                order_id: orderDetail.orderBase.order_id,
                customer_email: $('#emailInp').val(),
            });
            requireUpdataInter(updataData);
            break;
        case "#phoneInp":
            /*手机号*/
            var updataData = JSON.stringify({
                order_id: orderDetail.orderBase.order_id,
                received_phone: $('#phoneInp').val(),
            });
            requireUpdataInter(updataData);
            break;
        case "#linePhoneInp":
            /*固定电话*/
            var updataData = JSON.stringify({
                order_id: orderDetail.orderBase.order_id,
                customer_landline_phone: $('#linePhoneInp').val(),
            });
            requireUpdataInter(updataData);
            break;
    }
}

function updataCancel() {

    $("#alisaAddressInpBox").css({
        display: "none",
    });
    /*$("#addressInpBox").css({
		display: "none",
	});
	$("#consigneeInpBox").css({
		display: "none",
	});
	$("#alisaAddressInpBox").css({
		display: "none",
	});
	$("#emailInpBox").css({
		display: "none",
	});
	$("#phoneInpBox").css({
		display: "none",
	});
	$("#linePhoneInpBox").css({
		display: "none",
	});*/
}

function updataCancel1() {
    $("#addressInpBox").css({
        display: "none",
    });

}

function updataCancel2() {

    $("#consigneeInpBox").css({
        display: "none",
    });
}

function updataCancel3() {
    $("#emailInpBox").css({
        display: "none",
    });
}

function updataCancel4() {
    $("#phoneInpBox").css({
        display: "none",
    });
}

function updataCancel5() {
    $("#linePhoneInpBox").css({
        display: "none",
    });
}

function goToGoodsDetail(spuId) {
    sessionStorage.setItem("spuId", spuId);
    sessionStorage.setItem("spuId_order", spuId);
    var index = layer.open({
        type: 2,
        title: "Code详情",
        content: "../../goods/goods-sku.html"
    });
    layer.full(index);
}


//驳回弹框
var index = 0;

function dealmodal(id, val) {
    var curInd = layer.confirm('<span id="status" style="width:200px;height:100px;resize: none;" maxlength="200" >您确定要驳回吗</span>', {
        title: '提示',
        btn: ['确定', '取消']
    }, function (index) {

        finish1(id, curInd, val)
        layer.close(curInd);
    }, function () {
        layer.close(curInd);

    });
}

function finish1(id, val) {
    var target = document.getElementById('' + id + '');
    /*target.parentElement.parentElement.parentElement.previousElementSibling.innerHTML='关闭';*/
    console.log(target)

    var reason = $('#reason' + id + '').val();
    if (reason != '') {
        $.ajax({
            contentType: "application/json;charset=UTF-8",
            url: root.orderInter.order_rejectCancleApply,
            cache: false,  //禁用缓存
            type: "POST",
            dataType: 'json',
            data: JSON.stringify({
                "id": id,
            }),
            success: function (data) {
                console.log(data)

                target.onclick = null;
                target.setAttribute("onclick", 'confirm(' + id + ')')
                /*target.parentElement.parentElement.parentElement.previousElementSibling.innerHTML='关闭'*/
                getOrderDetail();

            },
            error: function () {
                $.Huimodalalert('失败！', 2000);
            }
        })
    } else {
        $.Huimodalalert('处理结果不能为空！', 2000);
    }
    ;
    layer.close(index);
}

function dealdemo(id, val) {
    layer.msg('客服跟进处理！');
    $.ajax({
        contentType: "application/json;charset=UTF-8",
        url: root.orderInter.order_followCancleApply,
        cache: false,  //禁用缓存
        type: "POST",
        dataType: 'json',
        data: JSON.stringify({
            "id": id,
        }),
        success: function (data) {

            getOrderDetail();
        },
        error: function () {
            $.Huimodalalert('失败！', 2000);
        }
    })


}

//退货申请单
var isIngReturn = false;

function returnGoods1(title) {
    if (isIngReturn) {
        // layer.msg('请求已提交，请勿重复点击！');
        return false;
    }
    isIngReturn = true;
    getOrderDetail();
    setTimeout(function () {
        var orderDetail = JSON.parse(sessionStorage.getItem("orderDetail"));
        var orderState = orderDetail.orderBase.order_status;

        var url = "orderSuccess_refund2.html";

        var index = layer.open({
            type: 2,
            title: title,
            content: url
        });
        layer.full(index);
    }, 200)
}

//发货
function Delivergoods() {
    //权限判断3
    var warehouse_ids =sessionStorage.getItem("regions")//主仓库

    var sales_manager_ids = sessionStorage.getItem("personnels")//人员
    var companys_ids=sessionStorage.getItem("companys")//客户归属&分公司

    //都没勾选
    if(warehouse_ids=="" && companys_ids=="") {
        $.Huimodalalert('暂无此订单处理权限！', 2000);
    }
    //只勾选仓
    if(warehouse_ids!="" && companys_ids=="") {

        var warehouse_idsAll=warehouse_ids.split(",");
        var isHas = false;
        for (var i = 0; i < warehouse_idsAll.length; i++) {
            console.log(warehouse_idsAll)
            if (warehouse_idsAll[i]==JSON.parse(sessionStorage.getItem("orderDetail")).orderBase.parent_warehouse_id) {
                $("#Expresssss").css({
                    display: "block"
                });
                if ($("#final_sent_type option:selected").text() == "快递") {
                    $("#bbbb").css({
                        display: "block"
                    });

                    $("#bbbb111").css({
                        display: "block"
                    });
                } else if ($("#final_sent_type option:selected").text() == "快运") {
                    $("#aaaa").css({
                        display: "inline"
                    });

                    $("#aaa111").css({
                        display: "inline"
                    });
                } else if ($("#final_sent_type option:selected").text() == "包车专车") {
                    $("#cccc").css({
                        display: "inline"
                    });

                    $("#ccc111").css({
                        display: "inline"
                    });
                }
                isHas = true;
                break;
            }
        }
        if(!isHas){
            $.Huimodalalert('暂无此订单处理权限！', 2000);
        }
    }

    //只勾线分公司
    if(warehouse_ids=="" && companys_ids!="") {
        //有没有勾选分公司
        //子仓库不为空,人员为空时
        if( companys_ids!=""&& sales_manager_ids=="") {

            var companys_idAll=companys_ids.split(",");
            var isHas = false;
            for (var t = 0; t < companys_idAll.length; t++) {
                if ( companys_idAll[t]==JSON.parse(sessionStorage.getItem("orderDetail")).orderExt.belong_groupId) {

                    $("#Expresssss").css({
                        display: "block"
                    });
                    if ($("#final_sent_type option:selected").text() == "快递") {
                        $("#bbbb").css({
                            display: "block"
                        });

                        $("#bbbb111").css({
                            display: "block"
                        });
                    } else if ($("#final_sent_type option:selected").text() == "快运") {
                        $("#aaaa").css({
                            display: "inline"
                        });

                        $("#aaa111").css({
                            display: "inline"
                        });
                    } else if ($("#final_sent_type option:selected").text() == "包车专车") {
                        $("#cccc").css({
                            display: "inline"
                        });

                        $("#ccc111").css({
                            display: "inline"
                        });
                    }
                    isHas = true;
                    break;
                }

            }
            if(!isHas){
                $.Huimodalalert('暂无此订单处理权限！', 2000);
            }
        }
        //子仓库,人员不为空时
        if( companys_ids!=""&& sales_manager_ids!="") {

            var sales_manager_idsAll=sales_manager_ids.split(",");
            var companys_idAll=companys_ids.split(",");
            var isHas = false;
            for (var j = 0; j < sales_manager_idsAll.length; j++) {
                for (var t = 0; t < companys_idAll.length; t++) {
                    if ( sales_manager_idsAll[j]==JSON.parse(sessionStorage.getItem("orderDetail")).orderExt.sales_manager_id || companys_idAll[t]==JSON.parse(sessionStorage.getItem("orderDetail")).orderExt.belong_groupId){

                        isHas = true;
                        break;

                    }
                }
            }
            if(!isHas){
                $.Huimodalalert('暂无此订单处理权限！', 2000);
            }else {
                $("#Expresssss").css({
                    display: "block"
                });
                if ($("#final_sent_type option:selected").text() == "快递") {
                    $("#bbbb").css({
                        display: "block"
                    });

                    $("#bbbb111").css({
                        display: "block"
                    });
                } else if ($("#final_sent_type option:selected").text() == "快运") {
                    $("#aaaa").css({
                        display: "inline"
                    });

                    $("#aaa111").css({
                        display: "inline"
                    });
                } else if ($("#final_sent_type option:selected").text() == "包车专车") {
                    $("#cccc").css({
                        display: "inline"
                    });

                    $("#ccc111").css({
                        display: "inline"
                    });
                }
                isHas = true;




            }
        }
    }
    //仓和分公司
    if(warehouse_ids!="" && companys_ids!="") {
        //主仓不为空，子仓库不为空,人员为空时
        if(warehouse_ids!="" && companys_ids!=""&& sales_manager_ids=="") {
            var warehouse_idsAll=warehouse_ids.split(",");

            var companys_idAll=companys_ids.split(",");
            var isHas = false;
            for (var d = 0; d < warehouse_idsAll.length; d++) {
                for (var t = 0; t < companys_idAll.length; t++) {
                    if (warehouse_idsAll[d]==JSON.parse(sessionStorage.getItem("orderDetail")).orderBase.parent_warehouse_id  || companys_idAll[t]==JSON.parse(sessionStorage.getItem("orderDetail")).orderExt.belong_groupId) {
                        isHas = true;
                        break;
                    }
                }
            }
            if(!isHas){
                $.Huimodalalert('暂无此订单处理权限！', 2000);
            }else {
                $("#Expresssss").css({
                    display: "block"
                });
                if ($("#final_sent_type option:selected").text() == "快递") {
                    $("#bbbb").css({
                        display: "block"
                    });

                    $("#bbbb111").css({
                        display: "block"
                    });
                } else if ($("#final_sent_type option:selected").text() == "快运") {
                    $("#aaaa").css({
                        display: "inline"
                    });

                    $("#aaa111").css({
                        display: "inline"
                    });
                } else if ($("#final_sent_type option:selected").text() == "包车专车") {
                    $("#cccc").css({
                        display: "inline"
                    });

                    $("#ccc111").css({
                        display: "inline"
                    });
                }
                isHas = true;




            }
        }
        //主仓不为空，子仓库不为空,人员不为空时
        if(warehouse_ids!="" && companys_ids!=""&& sales_manager_ids!="") {
            var warehouse_idsAll=warehouse_ids.split(",");

            var sales_manager_idsAll=sales_manager_ids.split(",");
            var companys_idAll=companys_ids.split(",");
            var isHas = false;
            for (var d = 0; d < warehouse_idsAll.length; d++) {
                for (var f = 0; f < sales_manager_idsAll.length; f++) {
                    for (var t = 0; t < companys_idAll.length; t++) {
                        if (warehouse_idsAll[d]==JSON.parse(sessionStorage.getItem("orderDetail")).orderBase.parent_warehouse_id  || sales_manager_idsAll[f]==JSON.parse(sessionStorage.getItem("orderDetail")).orderExt.sales_manager_id || companys_idAll[t]==JSON.parse(sessionStorage.getItem("orderDetail")).orderExt.belong_groupId) {


                            isHas = true;
                            break;
                        }
                    }
                }
            }
            if(!isHas){
                $.Huimodalalert('暂无此订单处理权限！', 2000);
            }else {
                $("#Expresssss").css({
                    display: "block"
                });
                if ($("#final_sent_type option:selected").text() == "快递") {
                    $("#bbbb").css({
                        display: "block"
                    });

                    $("#bbbb111").css({
                        display: "block"
                    });
                } else if ($("#final_sent_type option:selected").text() == "快运") {
                    $("#aaaa").css({
                        display: "inline"
                    });

                    $("#aaa111").css({
                        display: "inline"
                    });
                } else if ($("#final_sent_type option:selected").text() == "包车专车") {
                    $("#cccc").css({
                        display: "inline"
                    });

                    $("#ccc111").css({
                        display: "inline"
                    });
                }
                isHas = true;


            }
        }

    }



}

//发货取消快运按钮
function Expresscancel() {
    $("#Expresssss").css({
        display: "none"
    });

}

//发货取消快递按钮
function couriercancel() {
    $("#courier").css({
        display: "none"
    });

}

//发货取消专车包车按钮
function Limousinecancel() {
    $("#Limousine").css({
        display: "none"
    });

}

//发货确认快运按钮
function Expressconfirm() {
    var expresscompany = ''
    var expressnum = ''

    if ($("#final_sent_type option:selected").text() == "快递") {
        expresscompany = $("#express_company_two").val()
        expressnum = $("#express_num_two").val()
    } else if ($("#final_sent_type option:selected").text() == "快运") {
        expresscompany = $("#express_company_one").val()
        expressnum = $("#express_num_one").val()

    } else if ($("#final_sent_type option:selected").text() == "包车专车") {

        expresscompany = $("#driver_name").val() + $("#driver_phone").val()
        expressnum = $("#express_company_three").val()

    }
    $.ajax({
        contentType: "application/json;charset=UTF-8",
        url: root.orderInter.tempDeliver,
        cache: false,  //禁用缓存
        type: "POST",
        dataType: 'json',
        data: JSON.stringify({
            order_id: orderId,
            final_sent_type: $("#final_sent_type").val(),
            express_company: expresscompany,
            express_num: expressnum,
            /*driver_name:$("#driver_name").val(),
            driver_phone:$("#driver_phone").val(),
            deliver_name:$("#deliver_name").val(),
            deliver_phone:$("#deliver_phone").val()*/
        }),
        success: function (data) {
            $("#frglivergoods").css({
                display: "none"
            });
            $("#Expresssss").css({
                display: "none"
            });
            getOrderDetail();
        },
        error: function () {
            $.Huimodalalert('失败！', 2000);
        }
    })

}


//编辑司机
function toassddit1() {
    $("#driver-phone").removeAttr("readonly");

    $("#issdffsfsSaveTrue").css({
        display: "block"
    });
}

function toancle1() {
    $("#driver-phone").attr("readonly", "readonly");

    $("#issdffsfsSaveTrue").css({
        display: "none"
    });
    getOrderDetail();
}

function remaToSave1() {
    $("#driver-phone").attr("readonly", "readonly");
    $("#issdffsfsSaveTrue").css({
        display: "none"
    });
    /*if ( data.orderExt.final_sent_type==40 || data.orderBase.order_status!=60){
        $("#driver-phone").val(data.orderExt.driver_name + data.orderExt.driver_phone);
    }else {
        $("#driver-phone").val(data.orderExt.express_company);

    }*/
    $.ajax({
        contentType: "application/json;charset=UTF-8",
        url: root.orderInter.editTempDeliverInfo,
        cache: false,  //禁用缓存
        type: "POST",
        dataType: 'json',
        data: JSON.stringify({
            order_id: orderId,
            express_company: $("#driver-phone").val()

        }),
        success: function (data) {
            getOrderDetail();
        },
        error: function () {
            $.Huimodalalert('失败！', 2000);
        }
    })

}

//编辑配送员
function toassddit2() {
    $("#distributor-phone").removeAttr("readonly");

    $("#issdfsdfveTrue").css({
        display: "block"
    });
}

function toancle2() {
    $("#distributor-phone").attr("readonly", "readonly");

    $("#issdfsdfveTrue").css({
        display: "none"
    });
    getOrderDetail();
}

function remaToSave2() {
    $("#distributor-phone").attr("readonly", "readonly");
    $("#issdfsdfveTrue").css({
        display: "none"
    });
    $.ajax({
        contentType: "application/json;charset=UTF-8",
        url: root.orderInter.editTempDeliverInfo,
        cache: false,  //禁用缓存
        type: "POST",
        dataType: 'json',
        data: JSON.stringify({
            order_id: orderId,
            express_num: $("#distributor-phone").val()


        }),
        success: function (data) {
            getOrderDetail();
        },
        error: function () {
            $.Huimodalalert('失败！', 2000);
        }
    })

}

//编辑DC
function toassddit3() {
    $("#express_company").removeAttr("readonly");

    $("#issdfssSaveTrue").css({
        display: "block"
    });
}

function toancle3() {
    $("#express_company").attr("readonly", "readonly");

    $("#issdfssSaveTrue").css({
        display: "none"
    });
    getOrderDetail();
}

function remaToSave3() {
    $("#express_company").attr("readonly", "readonly");
    $("#issdfssSaveTrue").css({
        display: "none"
    });
    $.ajax({
        contentType: "application/json;charset=UTF-8",
        url: root.orderInter.editTempDeliverInfo,
        cache: false,  //禁用缓存
        type: "POST",
        dataType: 'json',
        data: JSON.stringify({
            order_id: orderId,
            express_num: $("#express_company").val()


        }),
        success: function (data) {
            getOrderDetail();
        },
        error: function () {
            $.Huimodalalert('失败！', 2000);
        }
    })

}

//编辑快递公司
function toassddit4() {
    $("#express_company2").removeAttr("readonly");

    $("#issdfsdfsfsSaveTrue").css({
        display: "block"
    });
}

function toancle4() {
    $("#express_company2").attr("readonly", "readonly");

    $("#issdfsdfsfsSaveTrue").css({
        display: "none"
    });
    getOrderDetail();
}

function remaToSave4() {
    $("#express_company2").attr("readonly", "readonly");
    $("#issdfsdfsfsSaveTrue").css({
        display: "none"
    });
    $.ajax({
        contentType: "application/json;charset=UTF-8",
        url: root.orderInter.editTempDeliverInfo,
        cache: false,  //禁用缓存
        type: "POST",
        dataType: 'json',
        data: JSON.stringify({
            order_id: orderId,
            express_company: $("#express_company2").val()


        }),
        success: function (data) {
            getOrderDetail();
        },
        error: function () {
            $.Huimodalalert('失败！', 2000);
        }
    })

}

//编辑快递单号
function toassddit5() {
    $("#express_num").removeAttr("readonly");

    $("#issdfsveTrue").css({
        display: "block"
    });
}

function toancle5() {
    $("#express_num").attr("readonly", "readonly");

    $("#issdfsveTrue").css({
        display: "none"
    });
    getOrderDetail();
}

function remaToSave5() {
    $("#express_num").attr("readonly", "readonly");
    $("#issdfsveTrue").css({
        display: "none"
    });
    $.ajax({
        contentType: "application/json;charset=UTF-8",
        url: root.orderInter.editTempDeliverInfo,
        cache: false,  //禁用缓存
        type: "POST",
        dataType: 'json',
        data: JSON.stringify({
            order_id: orderId,
            express_num: $("#express_num").val()


        }),
        success: function (data) {
            getOrderDetail();
        },
        error: function () {
            $.Huimodalalert('失败！', 2000);
        }
    })

}

//编辑实际配送方式
function toassddit6() {
    $("#final_sent").removeAttr("disabled");

    $("#isseTrue").css({
        display: "block"
    });
}

function toancle6() {
    $("#final_sent").attr("disabled", "disabled");

    $("#isseTrue").css({
        display: "none"
    });
    getOrderDetail();
}

function remaToSave6() {
    $("#final_sent").attr("disabled", "disabled");
    $("#isseTrue").css({
        display: "none"
    });
    $.ajax({
        contentType: "application/json;charset=UTF-8",
        url: root.orderInter.editTempDeliverInfo,
        cache: false,  //禁用缓存
        type: "POST",
        dataType: 'json',
        data: JSON.stringify({
            order_id: orderId,
            final_sent_type: $("#final_sent").val()


        }),
        success: function (data) {
            getOrderDetail();
        },
        error: function () {
            $.Huimodalalert('失败！', 2000);
        }
    })

}

//编辑快运公司
function toassddit7() {
    $("#express_company3").removeAttr("readonly");

    $("#isfsveTrue").css({
        display: "block"
    });
}

function toancle7() {
    $("#express_company3").attr("readonly", "readonly");

    $("#isfsveTrue").css({
        display: "none"
    });
    getOrderDetail();
}

function remaToSave7() {
    $("#express_company3").attr("readonly", "readonly");
    $("#isfsveTrue").css({
        display: "none"
    });
    $.ajax({
        contentType: "application/json;charset=UTF-8",
        url: root.orderInter.editTempDeliverInfo,
        cache: false,  //禁用缓存
        type: "POST",
        dataType: 'json',
        data: JSON.stringify({
            order_id: orderId,
            express_company: $("#express_company3").val()


        }),
        success: function (data) {
            getOrderDetail();
        },
        error: function () {
            $.Huimodalalert('失败！', 2000);
        }
    })

}

//编辑快运单号
function toassddit8() {
    $("#express_num3").removeAttr("readonly");

    $("#isfeTrue").css({
        display: "block"
    });
}

function toancle8() {
    $("#express_num3").attr("readonly", "readonly");

    $("#isfeTrue").css({
        display: "none"
    });
    getOrderDetail();

}

function remaToSave8() {
    $("#express_num3").attr("readonly", "readonly");
    $("#isfeTrue").css({
        display: "none"
    });
    $.ajax({
        contentType: "application/json;charset=UTF-8",
        url: root.orderInter.editTempDeliverInfo,
        cache: false,  //禁用缓存
        type: "POST",
        dataType: 'json',
        data: JSON.stringify({
            order_id: orderId,
            express_num: $("#express_num3").val()


        }),
        success: function (data) {
            getOrderDetail();
        },
        error: function () {
            $.Huimodalalert('失败！', 2000);
        }
    })

}

function safdsg() {

    if ($("#final_sent_type option:selected").text() == "快递") {

        $("#bbbb").css({
            display: "inline"
        });

        $("#bbbb111").css({
            display: "inline"
        });
        $("#aaaa").css({
            display: "none"
        });

        $("#aaa111").css({
            display: "none"
        });
        $("#cccc").css({
            display: "none"
        });

        $("#ccc111").css({
            display: "none"
        });
    } else if ($("#final_sent_type option:selected").text() == "快运") {
        $("#aaaa").css({
            display: "inline"
        });

        $("#aaa111").css({
            display: "inline"
        });
        $("#bbbb").css({
            display: "none"
        });

        $("#bbbb111").css({
            display: "none"
        });
        $("#cccc").css({
            display: "none"
        });

        $("#ccc111").css({
            display: "none"
        });
    } else if ($("#final_sent_type option:selected").text() == "包车专车") {
        $("#cccc").css({
            display: "inline"
        });

        $("#ccc111").css({
            display: "inline"
        });
        $("#bbbb").css({
            display: "none"
        });

        $("#bbbb111").css({
            display: "none"
        });
        $("#aaaa").css({
            display: "none"
        });

        $("#aaa111").css({
            display: "none"
        });
    }
}

//再次购买
function zaici() {
    //权限判断3
    var warehouse_ids =sessionStorage.getItem("regions")//主仓库

    var sales_manager_ids = sessionStorage.getItem("personnels")//人员
    var companys_ids=sessionStorage.getItem("companys")//客户归属&分公司

    //都没勾选
    if(warehouse_ids=="" && companys_ids=="") {
        $.Huimodalalert('暂无此订单处理权限！', 2000);
    }
    //只勾选仓
    if(warehouse_ids!="" && companys_ids=="") {

        var warehouse_idsAll=warehouse_ids.split(",");
        var isHas = false;
        for (var i = 0; i < warehouse_idsAll.length; i++) {
            console.log(warehouse_idsAll)
            if (warehouse_idsAll[i]==JSON.parse(sessionStorage.getItem("orderDetail")).orderBase.parent_warehouse_id) {
                $.ajax({
                    contentType: "application/json;charset=UTF-8",
                    url: root.orderInter.orderTake,
                    cache: false,  //禁用缓存
                    type: "POST",
                    dataType: 'json',
                    data: JSON.stringify({
                        orderId: orderId,
                        memberId: JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.user_ID,
                        loginAccount: JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.name

                    }),
                    success: function (data) {
                        if (data.errorCode == 0) {
                            $.Huimodalalert("下推成功！", 2000);
                        } else {
                            $.Huimodalalert(data.msg, 2000);
                        }


                    },
                    error: function () {
                        $.Huimodalalert('失败！', 2000);
                    }
                });
                isHas = true;
                break;
            }
        }
        if(!isHas){
            $.Huimodalalert('暂无此订单处理权限！', 2000);
        }
    }

    //只勾线分公司
    if(warehouse_ids=="" && companys_ids!="") {
        //有没有勾选分公司
        //子仓库不为空,人员为空时
        if( companys_ids!=""&& sales_manager_ids=="") {

            var companys_idAll=companys_ids.split(",");
            var isHas = false;
            for (var t = 0; t < companys_idAll.length; t++) {
                if ( companys_idAll[t]==JSON.parse(sessionStorage.getItem("orderDetail")).orderExt.belong_groupId) {

                    $.ajax({
                        contentType: "application/json;charset=UTF-8",
                        url: root.orderInter.orderTake,
                        cache: false,  //禁用缓存
                        type: "POST",
                        dataType: 'json',
                        data: JSON.stringify({
                            orderId: orderId,
                            memberId: JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.user_ID,
                            loginAccount: JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.name

                        }),
                        success: function (data) {
                            if (data.errorCode == 0) {
                                $.Huimodalalert("下推成功！", 2000);
                            } else {
                                $.Huimodalalert(data.msg, 2000);
                            }


                        },
                        error: function () {
                            $.Huimodalalert('失败！', 2000);
                        }
                    });
                    isHas = true;
                    break;
                }

            }
            if(!isHas){
                $.Huimodalalert('暂无此订单处理权限！', 2000);
            }
        }
        //子仓库,人员不为空时
        if( companys_ids!=""&& sales_manager_ids!="") {

            var sales_manager_idsAll=sales_manager_ids.split(",");
            var companys_idAll=companys_ids.split(",");
            var isHas = false;
            for (var j = 0; j < sales_manager_idsAll.length; j++) {
                for (var t = 0; t < companys_idAll.length; t++) {
                    if ( sales_manager_idsAll[j]==JSON.parse(sessionStorage.getItem("orderDetail")).orderExt.sales_manager_id || companys_idAll[t]==JSON.parse(sessionStorage.getItem("orderDetail")).orderExt.belong_groupId){

                        isHas = true;
                        break;

                    }
                }
            }
            if(!isHas){
                $.Huimodalalert('暂无此订单处理权限！', 2000);
            }else {
                $.ajax({
                    contentType: "application/json;charset=UTF-8",
                    url: root.orderInter.orderTake,
                    cache: false,  //禁用缓存
                    type: "POST",
                    dataType: 'json',
                    data: JSON.stringify({
                        orderId: orderId,
                        memberId: JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.user_ID,
                        loginAccount: JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.name

                    }),
                    success: function (data) {
                        if (data.errorCode == 0) {
                            $.Huimodalalert("下推成功！", 2000);
                        } else {
                            $.Huimodalalert(data.msg, 2000);
                        }


                    },
                    error: function () {
                        $.Huimodalalert('失败！', 2000);
                    }
                });
                isHas = true;





            }
        }
    }
    //仓和分公司
    if(warehouse_ids!="" && companys_ids!="") {
        //主仓不为空，子仓库不为空,人员为空时
        if(warehouse_ids!="" && companys_ids!=""&& sales_manager_ids=="") {
            var warehouse_idsAll=warehouse_ids.split(",");

            var companys_idAll=companys_ids.split(",");
            var isHas = false;
            for (var d = 0; d < warehouse_idsAll.length; d++) {
                for (var t = 0; t < companys_idAll.length; t++) {
                    if (warehouse_idsAll[d]==JSON.parse(sessionStorage.getItem("orderDetail")).orderBase.parent_warehouse_id  || companys_idAll[t]==JSON.parse(sessionStorage.getItem("orderDetail")).orderExt.belong_groupId) {
                        isHas = true;
                        break;
                    }
                }
            }
            if(!isHas){
                $.Huimodalalert('暂无此订单处理权限！', 2000);
            }else {
                $.ajax({
                    contentType: "application/json;charset=UTF-8",
                    url: root.orderInter.orderTake,
                    cache: false,  //禁用缓存
                    type: "POST",
                    dataType: 'json',
                    data: JSON.stringify({
                        orderId: orderId,
                        memberId: JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.user_ID,
                        loginAccount: JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.name

                    }),
                    success: function (data) {
                        if (data.errorCode == 0) {
                            $.Huimodalalert("下推成功！", 2000);
                        } else {
                            $.Huimodalalert(data.msg, 2000);
                        }


                    },
                    error: function () {
                        $.Huimodalalert('失败！', 2000);
                    }
                });
                isHas = true;





            }
        }
        //主仓不为空，子仓库不为空,人员不为空时
        if(warehouse_ids!="" && companys_ids!=""&& sales_manager_ids!="") {
            var warehouse_idsAll=warehouse_ids.split(",");

            var sales_manager_idsAll=sales_manager_ids.split(",");
            var companys_idAll=companys_ids.split(",");
            var isHas = false;
            for (var d = 0; d < warehouse_idsAll.length; d++) {
                for (var f = 0; f < sales_manager_idsAll.length; f++) {
                    for (var t = 0; t < companys_idAll.length; t++) {
                        if (warehouse_idsAll[d]==JSON.parse(sessionStorage.getItem("orderDetail")).orderBase.parent_warehouse_id  || sales_manager_idsAll[f]==JSON.parse(sessionStorage.getItem("orderDetail")).orderExt.sales_manager_id || companys_idAll[t]==JSON.parse(sessionStorage.getItem("orderDetail")).orderExt.belong_groupId) {


                            isHas = true;
                            break;
                        }
                    }
                }
            }
            if(!isHas){
                $.Huimodalalert('暂无此订单处理权限！', 2000);
            }else {
                $.ajax({
                    contentType: "application/json;charset=UTF-8",
                    url: root.orderInter.orderTake,
                    cache: false,  //禁用缓存
                    type: "POST",
                    dataType: 'json',
                    data: JSON.stringify({
                        orderId: orderId,
                        memberId: JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.user_ID,
                        loginAccount: JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.name

                    }),
                    success: function (data) {
                        if (data.errorCode == 0) {
                            $.Huimodalalert("下推成功！", 2000);
                        } else {
                            $.Huimodalalert(data.msg, 2000);
                        }


                    },
                    error: function () {
                        $.Huimodalalert('失败！', 2000);
                    }
                });
                isHas = true;



            }
        }

    }


}

//查看附件
function enclosures() {
    sessionStorage.setItem("orderid", orderId)
    layer_show("查看附件", "Enclosure.html", "800", "600");
}
//操作日志
function operationlog() {
    sessionStorage.setItem("orderIds",orderId)
    var title="操作日志"
    var url="operationLog.html"
    var index = layer.open({
        type: 2,
        title: title,
        content: url
    });
    layer.full(index);
}
//查看取货方式
function pickupinformation() {
    $.ajax({
        type: "POST",
        url: root.orderInter.getSelfTakeDeliveryInfo,
        cache: false, //禁用缓存
        dataType: "json",
        data: {
            order_id: orderId, // 订单编号
        },
        success: function (result) {
            if(result.errorCode==0){
                $("#pickupinformation").modal("show");
                // 根据订单号生成二维码
                var orderids=result.data.order_id
                $("#qRCode").html("")
                var qrcode = new QRCode(document.getElementById("qRCode"), {
                    width : 98,
                    height : 98
                });
                qrcode.makeCode(orderids);
                //渲染数据
                $("#self_takeshop").html(result.data.self_take_shop)
                $("#self_takein").html(result.data.self_take_in)
                $("#self_take_warehouse").html(result.data.self_take_warehouse)
                $("#verify_code").html(result.data.verify_code)


            }else {
                $.Huimodalalert(result.msg, 2000);
                getOrderDetail()
            }
        }
    });


}
//下推订单
function pushOrder() {
    $.ajax({
        contentType: "application/json;charset=UTF-8",
        url: root.orderInter.pushOrder,
        cache: false,  //禁用缓存
        type: "POST",
        dataType: 'json',
        data: JSON.stringify({
            order_id: orderId,
            operator_id: JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.user_ID,
            operator_name: JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.name

        }),
        success: function (data) {
            if (data.errorCode == 0) {
                $.Huimodalalert("订单已加入下推列队，成功与否请稍后查看", 2000);
                pushOrdererrorCode=0
                getOrderDetail()
            } else {
                $.Huimodalalert(data.msg, 2000);
                pushOrdererrorCode=1
                getOrderDetail()
            }
        },
        error: function () {
            $.Huimodalalert('失败！', 2000);
        }
    });
}
//下推订单结果
function pushOrder2() {
    $("#pushOrderinformation").modal("show");
    if(pushOrdererrorCode==1){
        $("#nos").css({
            display: "inline"
        });
        $("#reasons").html(JSON.parse(sessionStorage.getItem("orderDetail")).push_message)
    }else {
        $("#nos").css({
            display: "none"
        });
        $("#reasons").html("订单已加入下推列队，成功与否请稍后查看")
    }

}
//补开发票
function supplementarys(title,url) {
    var datas=sessionStorage.getItem("supplementOrderid")
    var platforms=sessionStorage.getItem("supplementPlatform")
    var memberids=sessionStorage.getItem("supplementmemberid")
    var customerids=sessionStorage.getItem("supplementcustomerid")
    sessionStorage.setItem("supplementOrderid",datas);
    sessionStorage.setItem("supplementPlatform",platforms);
    sessionStorage.setItem("supplementmemberid",memberids);
    sessionStorage.setItem("supplementcustomerid",customerids);
    var index = layer.open({
        type: 2,
        title: title,
        content: url
    });
    layer.full(index);
}